Programmer can customize the finialize() method of the class he's developing, In fact you are supposed to define all cleanup code (like relinquishing resources etc.) in a finaize() method though you are not really sure when it will get called
And since every class by default extends from Object class, finalize() got to have protected to get derived in sub-classes.
Joined: Apr 20, 2003
Yes i agree with that, But to implement it it need not be protected , it can also be public like all other important operations in Object
For example equals(), hascode(), and toString().
I do not see any specific reason for it to be protected.
Joined: Dec 13, 2004
public methods are used when some other code is supposed to invoke the method. but finalize() is a callback method, means its called by GC thread before desroying an object. No other part of code ever calls finalize() method. Then why to make it public unnecessarily.