Way2Java

final finally finalize Java

final finally finalize Java

Summary: A Java beginner gets confused with "final finally finalize Java". Explained in simple terms. Go through.

final and finally are keywords of Java doing different jobs. No comparison between them because they work for different jobs. finalize() is a method.

1. final

Keyword final can be applied in three places – variables, methods and classes and in each place they it perform different jobs.

2. finally

Keyword finally is used in combination with try block in exception handling. The statements of finally block are guaranteed of execution.

3. finalize

finalize() method is from Object class. It is called by the JVM before an object is garbage collected.