14.3 What is the difference between final, finally, and finalize?
This topic examines three of our Java final,finally and finalize keywords that look very similar to each other.
Don't look at them like three long, but it's not the same thing at all. Final is used before a variable, method, or class to indicate whether it is changeable. And finally is used in the Try/catch module, but the table of code is always executed. The Finalize method is called by the garbage manager when no references exist. Below to further differentiate them:
Final
Variables that act on the primary type: The value of the variable cannot be changed
Variables that work on reference types: Reference variables cannot point to other objects in the heap
Acting on a method: The method cannot be overridden
Acting on a class: The class cannot have subclasses
Finally
Finally block can be a try or catch, the inside of the code will always be executed (except the virtual machine or thread in the Try/catch end)
Finalize ()
The Finalize () method is called by the garbage collection mechanism when no reference exists. Regular backup to clean up resources, such as closing a file.
[Careercup] 14.3 Final Finally Finalize the keyword comparison