62,615
社区成员
发帖
与我相关
我的任务
分享
class Student{
public static int num;
public Student(){
num++;
}
}
public class T {
private static int i = 0;
public T() {
i++;
}
public static int getNumber() {
return i;
}
public static void function(){
i--;
}
public static void main(String[] args) {
T t1 = new T();
T t2 = new T();
T t3 = new T();
T t4 = new T();
System.out.println("一共创建了" + T.getNumber() + "个对象");
t1=null;
T.function();
t2=null;
T.function();
....
....
}
}
}