What is the difference between final, finally and finalize in java?

Final means a modifier. If you use it to modify a class, the class cannot be inherited; if you use it to modify a variable, the variable cannot be modified once it is assigned; if you use it to modify a method, then This method cannot be overridden. Cannot be overloaded.

Finally is used for exception handling, it is used to decorate a code block, even if the previous code handles the exception, the code in the code block will be executed. Usually used to release resources.

finalize represents a method defined in the Object class, which can be overridden to reclaim resources.

Guess you like

Origin blog.csdn.net/weixin_55580097/article/details/114247159
Recommended