Re: [問題] 在物件被註銷時自動執行某些事
因為java沒有destructor
而且不能保證物件何時被release掉
所以不能像c++一樣用物件管理資源
JSE 7 以後新增了 try-with-resources Statement
http://www.javacodegeeks.com/2011/07/java-7-try-with-resources-explained.html
可以少寫一些東西....
或是用這個
Execute Around Pattern
http://stackoverflow.com/questions/341971
如果你很堅持的話...自己實作reference count
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.104.186.35
※ 編輯: aleelyle 來自: 59.104.186.35 (06/12 20:35)
※ 編輯: aleelyle 來自: 59.104.186.35 (06/12 20:36)
推
06/13 13:58, , 1F
06/13 13:58, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 7 篇):