62,612
社区成员
发帖
与我相关
我的任务
分享
public class Garbage {
int index;
static int count;
Garbage(){
count++;
System.out.println("Garbage #"+count+" construct");
setID(count);
}
public void setID(int id){
index=id;
}
@Override
protected void finalize(){
System.out.println("Garbage #"+index+" is clear away");
}
public static void main(String[] args){
new Garbage();
new Garbage();
new Garbage();
new Garbage();
new Garbage();
new Garbage();
System.gc();
}
}