This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread 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 Android Security Essentials Live Lessons this week in the Android 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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: finalize()
Similar Threads
finally , finalize()
Gc question
Garbage Collection
why finalize() can't be defined as private?
Finalization Method