In "Thinking in Java" chapter 4 question 11 and 12 are as follows:
11. Create a class with a finalize( ) method that prints a message. In main( ), create an object of your class. Explain the behavior of your program. Comment 12. Modify Exercise 11 so that your finalize( ) will always be called. Comment
I thought we can not be certain that finalize will be called. It is up to JVM even after System.gc call
I'm not sure if this is what the book meant... but you could call the finalize() method from a try/finally block. The finally should 'always' be executed, unless the thread is killed or system.exit happens first. Barbara Hart
protected void finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. ... The finalize method is never invoked more than once by a Java virtual machine for any given object. ...
[ August 15, 2002: Message edited by: Valentin Crettaz ]
I'm pretty sure that not all of us have the F: drive mapped the same as yours. Anyway, using the finalize() method is generally not advisable, as it's execution is unpredictable. Paul [Link fixed by Val] [ August 15, 2002: Message edited by: Valentin Crettaz ]