• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collector: Default Behavior

 
Rodney Woodruff
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I call finalize() on an object before the garbage collector will the garbage collector still call finalize() on that object? This question stems from the fact that the finalize method will only be called on an object once in its lifetime.
Thanks for all your help.
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Rodney, the finalize() method may still be called (once) by the gc even if you manually call it.
*ANY* method you create, you are free to call. You can even call your own main() method.
It's just that some methods are entry points that the VM uses to control your app, and they are well-known, like main() and finalize().
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic