View RSS Feed

Recent Blogs Posts

  1. Final, finally and finalize

    by , 01-08-2012 at 12:38 PM
    • final – It’s a constant declaration.

    • finally – It handles exception. It is an optional block to write at the end of your exception handling block. It is usually used to close files, close database connections and statements. Also release all other resources in this block.

    • finalize – This method is called by the garbage collector. Garbage collector always called this method before it performs garbage collection on that object. It should not be used to release ...
    Categories
    Access Modifier
  2. Finalize

    by , 05-24-2011 at 02:46 PM (My Java Tips)
    All Java classes inherits the finalize() method from java.lang.Object and this method is called by the garbage collector when it determines no more references to the object exist.

    The finalize method performs no actions but it may be overridden by any class. It is overridden to clean-up non-Java resources ie closing a file, closing a connection etc. In overridding finalize() it is a good programming practice to use a try-catch-finally statement and to always call super.finalize(). ...
    Tags: finalize Add / Edit Tags
    Categories
    Java SE