Java Exception Handling

Java final vs finally vs finalize

Given below is the difference between final, finally and finalize in java.


final vs finally vs finalize




final is a keyword in java

finally is a block in java

finalize is a method in java

final in java can be used with :


  • variable - If you mark a variable as final then once you initialize value to that variable, it can never be changed.
  • method - If you mark a method as final in your class then that method cannot be overridden by the sub-classes method.
  • class - If you mark a class as final in java then that class cannot be extended (or sub-classsed)


finally block is used with try block in exception handling. This block will surely get executed irrespective of whether exception is handled or not. 

finalize() method is called at least once, before the object is garbage collected, to perform any cleanup activity like releasing any system resources if held or closing the open connection.


final is used with variable or method or class to put certain restrictions.

finally is associated with exception handling mechanism. It is either followed by try-catch block or try block

finalize is associated with memory management. 


Please Share this page
Views : 122
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!