ball ball路过大佬看下关于修改了static变量后的输出结果的小小代码
class A {
static int i = 0;
int j = 1;
A(int j) {
this.j = j;
i++;
}
}
class Test {
public static void main(String[] args) {
A a1 = new A(2);
A a2 = new A(5);
System.out.println(a1.i + " " + a1.j + " " + a2.i + " " + a2.j);
}
}
为什么输出的是2 2 2 5而不是1 2 25