源码
public class statics {
public static int num;
public statics()
{
num++;
}
public static void main(String[] args)
{
num=0;
statics a=new statics();
statics b=new statics();
statics c=new statics();
System.out.printf("你已经创建了%d个对象",num);
}
}
运行结果
你已经创建了3个对象