class A {
public A() {
System.out.println("A construct");
}
@Override
public void finalize() {
System.out.println("A finalize");
}
}
class B extends A{
String name;
int age;
public B(String name, int age) {
this.name = name;
this.age = age;
System.out.println("B construct "+name+" is "+age);
}
@Override
public void finalize() {
System.out.println("B finalize");
super.finalize();
}
}
public class Main {
public static void main(String[] args) throws Exception {
A a = new B("allen", 20);
a=null;
System.gc();
}
}
/*A construct
B construct allen is 20
B finalize
A finalize*/