查看创建对象的个数
package 作业1;
public class Student{
public static void main(String[] args){
Information a = new Information();
a.OutputInformation();
Information b = new Information();
b.OutputInformation();
}
}
class Information{
static int num=0;
Information(){
num++;
}
public void OutputInformation() {
System.out.println("你已经创建了"+num+"个对象!");
}
}