final can modify classes, member variables, local variables and methods.
1.Final modified member variables
1.Initialization of final member variables
For final modified variables, the system will not initialize them to 0 by default.
fina variable initialization method:
2.final modification method
When final is used to modify a method, it means that this method cannot be overridden by subclasses.
3.final modified class
Final-modified columns are not allowed to be inherited. The compiler treats all its methods as final during processing, so final classes are more efficient than ordinary classes. The abstract column defined by the keyword abstract contains abstract methods that must be overloaded by subclasses inherited from it, so the same class cannot be modified with final and abstract at the same time. For the same reason, final cannot be used to modify interfaces. Final class methods cannot be overridden. But this does not mean that the attribute values of final classes are also immutable. If you want to make the attribute value of a final class unchangeable, you must add the final modifier to it.
The finally statement can only be used in try/catch statements and is accompanied by a statement block, indicating that this statement will always be executed eventually.
First calculate the value of the expression after return and temporarily store the value. Then calculate the value of the expression after return in finally. After calculation, it will also be temporarily stored.
At this time, the previously stored value will be overwritten. Finally, go back to the previous return, take out the value from where the variable is temporarily stored, and return. That is, this result was obtained.