//信1603
//查询创建了多少个对象
//2017.10.19
public class Lei
{
//记录对象个数
static int x=;
//生成一个对象就自加加
public Lei()
{
x++;
}public static void main(String[] args)
{
Lei L1=new Lei();
Lei L2=new Lei();
Lei L3=new Lei();
Lei L4=new Lei();
Lei L5=new Lei();
Lei L6=new Lei();
Lei L7=new Lei();
// L1.ceshi();
System.out.println("创建对象数量"+x);
}
}
程序截图: