1. Final modifier (keyword)
If a class is declared final, it means that it can no longer derive a new subclass and cannot be inherited as a parent class. Therefore, a class cannot be declared both abstract and final.
Declaring variables or methods as final ensures that they are not changed in use. Its initialization can be in two places:
The first is its definition , that is, to assign the value directly to the final variable definition;
The second is in the constructor . These two places can only be selected, either in the definition of the value, or in the constructor to give a value, not both in the definition of the value, but also in the constructor to give additional values, and in subsequent references can only read, not modifiable. A method that is declared final can also be used only and cannot be overridden (override).
2. Finally
Provides a finally block to perform any cleanup operations during exception handling. If an exception is thrown, the matching catch clause executes, and the control enters the finally block, if any. Use finally to maintain the internal state of an object and to clean up non-memory resources. If you don't have a finally, your code will be confusing.
3. Finalize
Finalize is the method name. Java technology allows the use of the Finalize () method to do the necessary cleanup before the garbage collector clears objects from memory. This method is called by the garbage collector to this object when it determines that the object is not referenced. It is defined in the object class, so all classes inherit it. Subclasses override the Finalize () method to organize system resources or perform other cleanup work. The Finalize () method is called on the object before the object is deleted by the garbage collector.
Java Fundamentals strengthen 98:final, finally, finally difference