课后作业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()
{}
}

运行结果截图:

 

posted @ 2017-10-18 17:10  喜欢沧月的二福君  阅读(82)  评论(0编辑  收藏  举报

联系博主qq2456891380