局部变量x重复

我在for循环中遇到问题,说这是重复的局部变量?我仍在尝试了解这一点,并已尽我所能调查了答案,因此我现在向大家询问。如果您不介意,我想解释一下为什么它不起作用?


int x = 3;

String name = "Dirk";

x = x * 17;

System.out.print("x is " + x);

double d = Math.random();


while (x > 12) {

    x = x - 1;

}


for (int x = 0; x < 10; x = x + 1) {

    System.out.print("x is now " + x);

}


if (x == 10) {

    System.out.print("x must be 10");

} else {

    System.out.print("x isn't 10");

}

if ((x < 3) & (name.equals("Dirk"))) {

    System.out.println("Gently");

}


慕村225694
浏览 179回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java