JAVA 静态变量与构造函数问题
public class ValueTwo {
static int b=0;
public ValueTwo(int v){
b=v;
}
public void cumulate()
{
b++;
}
}
-----------------------
public class TestValueTwo {
private void prin(int a){
System.out.println(a);
}
ValueTwo vt=new ValueTwo(10);
public static void main(String args[]){
ValueTwo vt1=new ValueTwo(1);
TestValueTwo tt=new TestValueTwo();
tt.prin(vt1.b);
vt1.cumulate();
tt.prin(vt1.b);
}
}
问题是:不是打印出为什么打印出来是10,11而不是1,2呢?
明明根据ValueTwo vt1=new ValueTwo(1); 后b=1的。