Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is there a destructor method?  RSS feed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or some method that is called just before an object is destroyed?
 
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The finalize() method is called before an object is garbage collected. The problem is, though, that there's no guarantee than any given object will ever be collected -- if the memory is never needed, it may not be reclaimed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!