java课后作业
程序源代码:
public class NumberOfObject
{
public static int count=0;
NumberOfObject()
{
count++;
System.out.println("Constructor is going on!!!");
}
public static void main(String args[])
{
NumberOfObject Obj1=new NumberOfObject();
NumberOfObject Obj2=new NumberOfObject();
NumberOfObject Obj3=new NumberOfObject();
NumberOfObject Obj4;
System.out.println("Number Of Object is:"+NumberOfObject.count);
}
}
程序运行结果: