例如此代码:
class Test
{
private int num = 1;
Test(int x)
{
}
public void setNum(int x)
{
this.num=x+2;
}
public int getNum()
{
return num;
}
}
class TestDemo
{
public static void main(String[] args)
{
Test t = new Test(1);
System.out.println(t.getNum());
}
}
为什么打印的不是3而是1呢?