public class TestGc {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new Dog(1,"wangwang");
new Dog(2,"haha");
System.gc();
}
}
class Dog
{
public Dog(int id, String name) {
super();
this.id = id;
this.name = name;
}
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private String name;
@Override
protected void finalize() throws Throwable {
super.finalize();
}
} |