First a question Bindesh how do you cite other's responses? I do not know to do it
>If the finalize method is called the CombineSimple object is >unrechable..
The g.c. calls a finalize if the object is not strong, soft or weakly reachable. So we can say that a finalize method is only called when there are not references to the object apart from a phantom one.
>It is not doing cleanup at all since you override it to print >messages only.
What else could be done in this example?
>To ensure cleanup is performed you should call
>super.finalize() and define any special task that GC can't take >care of,file,Connections,etc.After all this finalize,
super.finalize() it is only needed if the parent class defined finalize() otherwise the finalize method defined in Object does nothing.
Bruce Eckel tell us that these kind of operations are risky to execute whithin a finalize precisely because the uncertenty of the execution of the finalize method for a particular object.
So it's better doind them in a separate method called when you have done with the object.
Read more about this on
artima.com , a site by Bill Venners who kindly put on line some chapters of his book Inside The
Java 2 Virtual Machine
Or downlodad the excellent book Thinking in Java by Bruce Eckel from bruceeckel.com