如下面代码:
public class Test
{
static int a = 0;
public Test()
{
a++;
}
public static void main(String[] args)
{
Test t1 = new Test();
Test t2 = new Test();
System.out.println(t1.a);
System.out.println(t2.a);
System.out.println(a);
System.out.println(Test.a);
}
}
输出为:
2
2
2
2