« Graham Ellis - an Introduction | Main | Serialization in Java - all layers required! »
February 05, 2007
Final, Finally and Finalize - three special words in Java
A final method or variable is one that can't be overridden - you can define a method as final within a class to ensure that any extensions to the class don't replace it.
If you add a finally block onto the end of a try / catch exception handler, you're defining a block of code that will be run if the try is entered, even if problems occur and your method returns from within a catch rather than continuing.
A finalize method is your destructor method - code that's run to clean up objects that are no longer required. For example, objects which are memory cached would be flushed back to the disc in your finalize.
Posted by gje at February 5, 2007 08:08 AM