help 构造函数问题,难度大
class Test{
public Test(){
System.out.println ("Test is live");
}
public void finalize(){
System.out.println ("Test is Dead");
}
}
class Test2 extends Test{
public Test2(){
System.out.println ("Test2 is live");
}
public void finalize(){
System.out.println ("Test2 is Dead");
}
public static void main(String[] args){
Test2 t = new Test2();
Runtime.getRuntime().gc();
t = null;
Runtime.getRuntime().gc();
}
}
Test is live
Test2 is live
Test2 is Dead
为什么 Test 的构造函数被调用了
但是没有生成 Test 的对象