Significance of Finalize method.- The Finalize method of an object is called when GC(Garbage Collector) is about to cleanup the object.
- We can keep cleanup code in the finalize block.
- It is the last chance for any object to perform the cleanup activity.
- Finalize method is defined in 'java.lang.Object' class.
- Any exception is thrown by finalize method.
- The 'System.runFinalization()' and 'Runtime.getRuntime().runFinalization' methods increases the probability of finalize method.
|