}
public class Test {
private static int n = 0;
public Test() {
n++;
}
public static int getNum() {
return n;
}
public static void main(String[] args) {
Test t1 = new Test();
Test t2 = new Test();
Test t3 = new Test();
System.out.println("已生成对象个数为:" + Test.getNum());
}
}