Thursday, January 20, 2011

Final,Finally,Finalize

Final


Final is a keyword.
Final keyword is used three ways in java
  • Creating constants
  • Prevent the overriding
  • Prevent Inheritance


Finally


Finally is a keyword.
When your code throws an exception an exception it stops processing the remaining code in your method and exits the method if the method having the same locale resource creation. That kind of local resource are know to that method only. So before comes out of the method to cleanup the local resources. Here finally clause is used to cleanup the local resource . before method comes out.

Finalize


Finalize is method of Object class.
Sometimes an object will need to perform some action when it is destroyed. For example if an object id holding some non- java resource such as a file handler or character font, then you might want to make sure these resource are freed before an object is destroyed to handle such situations java provides a mechanism called finalization.

No comments:

Post a Comment