【发布时间】:2025-12-05 06:20:06
【问题描述】:
import comp102x.IO;
public class testing {
private int x;
public testing(int x) {
x = x;
}
public static void main(String[] args) {
testing q1 = new testing(10);
IO.outputln(q1.x);
}
}
为什么输出是 0 而不是 10?这是一个 JAVA 脚本。实例和局部变量的概念让我很困惑,有人可以帮忙解释一下吗?
【问题讨论】:
-
你认为这条线的作用是什么:
x = x;?