Main Content
Final, Finally and Finalize - three special words in Java Archive - Originally posted on "The Horse's Mouth" - 2007-02-05 08:08:00 - Graham Ellis
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.
Some other articles
J712 - Exceptions Java Utility class - flexible replacement for array. Also cacheing in objects and multiple catch clauses example. Keyboard reader for Java programming newcomers String handling - from first steps to practical examples After Course Resources - do we publish sample answers. Example from Java Exceptions module. Fail Safe Error Handling in Java via Exceptions Handling unusual and error conditions - exceptions Exceptions in Java - why and how What are exceptions - Python based answer This article J710 - Extending Classes and More Objects - from physical to virtual or abstract - Java Java Inheritance example - group of classes - step by step Philosophy behind object design - and how I applied in to a Java example Changing what operators do on objects - a comparison across different programming languages Splitting out code into name blocks for clarity and reusability What is a universal superclass? Java / Perl / Python / Other OO languages What methods are available on this Java object? Tips for writing a test program (Ruby / Python / Java) Abstract classes, Interfaces, PHP and Java Abstract Classes - Java Calling base class constructors Java - a demonstration of inheritance on just one page Teaching Object Oriented Java with Students and Ice Cream Java - using super to call a method in the parent class An example of Java Inheritance from scratch What are factory and singleton classes? This article Comparison of Object Oriented Philosophy - Python, Java, C++, Perl Think about your design even if you don't use full UML G996 - Newsletter Scripts Oops - I typed ci not vi, and have lost my file ... Changing Images Controlling, supressing, enabling PHP error messages Error Handling in Lua with assert and pcall Grouping rows for a summary report - MySQL and PHP Using the internet to remotely check for power failure at home (PHP) Finding variations on a surname mod_rewrite for newcomers Ajax - going Asyncronous and what it means First class functions in Lua lead to powerful OO facilities Factory method example - Perl Replacing the last comma with an and Script to present commonly used images - PHP Efficient PHP applications - framework and example Error logging to file not browser in PHP Resetting session based tests in PHP What are factory and singleton classes? mysqldump and mysqlrestore This article .pdf files - upload via PHP, store in MySQL, retrieve