Re: [問題] 解構的順序

看板java作者 (Is freelancer free?)時間18年前 (2008/03/15 19:36), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串5/8 (看更多)
※ 引述《superlubu (叔叔你人真好)》之銘言: : public class c extends b { : public c() { System.out.println("instance of class c, created."); } : protected void finalize() throws Throwable { : System.out.println("instance of class c, finalized."); : } : public static void main(String arg[]) throws Exception { : c obj = new c(); : obj = null; : System.gc(); : Thread.sleep(6000000); : } : } : 結果如下: : instance of class a, created. : instance of class b, created. : instance of class c, created. : instance of class c, finalized. 呵, 要呼叫 super.finalize() 才行啊 http://farm3.static.flickr.com/2007/2334136379_5d6b7a484d_o.png
(tij, p333) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.133.80.216

03/15 19:44, , 1F
嗯...所以比較合理的作法似乎是吧 super.finalize() 放最後?
03/15 19:44, 1F
文章代碼(AID): #17sxIY4r (java)
討論串 (同標題文章)
文章代碼(AID): #17sxIY4r (java)