作业
mport java.util.Random;public class MathProblemGenerator { public static void main(String[] args) { Random rand = new Random(); for (int i = 1; i <= 30; i++) { int a = rand.nextInt(50) + 1; int b = rand.nextInt(50) + 1; String[] ops = {"+", "-", "*", "/"}; String op = ops[rand.nextInt(4)]; System.out.println(i + ". " + a + " " + op + " " + b + " = "); } }}运行结果X+Y=100200300=X+Y结果分析第一句:"X+Y=" + X + Y 中,从左到右执行,先拼接字符串 "X+Y=100",再拼接 "200",结果为 "X+Y=100200"。 第二句:X + Y + "=X+Y" 中,先计算 X + Y(整数加法得 300),再与字符串拼接,结果为 "300=X+Y"。运行结果falsefalsetrueSMALLMEDIUMLARGE