class Person
{
public void finalize()
{
System.out.println("the object is going!");
}
public static void main(String [] args)
{
new Person();
new Person();
new Person();
System.gc();
System.out.println("the program is ending!");
}
}
编译运行的结果如下:
the object is going!
the object is going!
the object is going!
the program is ending!