Difference between final, finally, finalize()

Below is difference between final, finally and finalize() is entirely different.

final and finally are keywords.finalize is a method.

final

is a keyword, which is used for below purpose
1. To declare constants.
2. To define final class.
3. To declare final methods.

finally

is a keyword, which is used in exception handling. finally block can exist only along with try and catch block. code enclosed in finally block gets executed irrespective of exception occurring or not.

finalize()

is method actually declared in Object class(which is base class of all classes in Java). This method can be overridden by any class, for garbage collection purpose.The java run time calls this method whenever it is about to recycle an object of the class

One thought on “Difference between final, finally, finalize()”

Leave a Reply