my dog learned polymorphism
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes finalize() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "finalize()" Watch "finalize()" New topic



Joined: Jun 16, 2001
Posts: 26
finalize() only call one time
so, finalize() can overload?

Michelle<br />SCJP<br />OCP Developer 2, 6/6i
kaushik banerjee
Ranch Hand

Joined: Mar 11, 2001
Posts: 56
u're bang on target . finalize() can be overlaoded but the one with the original signature will be called.
protected void finalize() throes Throwable
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
A finalizer is a method from class Object that any class may OVERRIDE. To OVERLOAD method "finalize()" would be futile since when it is used it MUST have the following signature:
protected void finalize() throws Throwable {
//do finalization stuff
Remember that although the "finalize()" override MAY be called on dead instances of the associated class before the memory occupied by that object is reused, to guarantee that it will be called is to use the method "System.runFinalizersOnExit(}" in the class as well.
I agree. Here's the link:
subject: finalize()
It's not a secret anymore!