File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Doubt about garbage collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt about garbage collection" Watch "Doubt about garbage collection" New topic

Doubt about garbage collection

yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120

my question is memory is reclaimed for which object here??

finalize will run for which object?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

The garbage collector will call the finalize() method of an object it's about to dispose of. The finalize() you supply here is in the class CheckGC; since no CheckGC objects are ever created, this finalize() will never be called. If the Date class had a finalize() method, then it could be called many times because of all the Date objects being created and discarded.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Doubt about garbage collection