Hi
Can we call finalize() method in Java?
Finalize() method in Java
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Nov 9, 2011, 1:25 PM EST
It's usually best to leave it to the JVM to call the finalize() method just before the object is destroyed and its memory is recovered.
AartiRank #2,383 · 594 reputationPosted Nov 16, 2011, 7:52 PM EST
Yes. Nobody will stop us to call any method , if it is accessible in our class. But a garbage collector cannot call an object's finalize method if that object is reachable.
Regards,