SiteMap  | About    

What is difference between final, finally and finalize?


Final is a keyword and it can be used to mark a variable "unchangeable" . Actually, it is used to apply restrictions on class, method and variable. Final class can't be inherited, final method can't be overridden and final variable value can't be changed. An object can also be final, which means that the once the object is created it cannot be assigned a different object, although the properties or fields of the object can be changed.



Finally is a code block. It is used with try-catch block for handling exception. finally code block will be executed whether exception is handled or not



Finalize is a method of Object class. It is invoked before an object is discarded by the garbage collector , allowing it to clean up its state.

Example (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.