程序代码:
public class text1 {
public static void main(String arg[])
{
text b=new text();
text c=new text();
text d=new text();
text e=new text();//还可以继续创建
System.out.println("你已经创建了"+text.a+"个对象");
}
}
class text
{
static int a=0;
{
++a;
}
public void add()
{}
}
运行结果截图: