课后作业3(创建对象)

程序代码:


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()
{}
}

运行结果截图:

https://necydcy.me/
原文地址:https://www.cnblogs.com/miria-486/p/7687709.html