JAVA: final, finally, finalize
Difference between final, finally, finalize
In JAVA
final
final is a modifier accessible for class, method and variables
Class declared as final then you can not extend that class. You can not create child class for that class.
Method declared as final than you can not override that method in the child class.
Variable declared as a final then that variable become constant and you can not change its value.
finally
finally is a block in java used in exceptional handling always associated with try and catch to maintain cleanup code
eg.
try
{
// Risky code ( the code might raise //exception)
}
catch
{
// Handling code ( the code to handle the //exception
}
{
cleanup code
}
finally meant for cleanup activities related to try block.
finalize
finalize is a method always invoked by garbage collector just before vanishing an object to perform cleanup activities.
finalize meant for cleanup activities related to object
Comments
Post a Comment