统计对象创建个数
public class CoutObject {
public static void main(String[] args) {
CoutObject t1=new CoutObject();
CoutObject t2=new CoutObject();
System.out.println("创建对象个数:"+CoutObject.getNum());
}
public static int n;
public CoutObject()
{
n++;
}
public static int getNum()
{
return n;
}
}