This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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.
It is sorta covered in the JavaRanch Style Guide.
subject: finalize()