Final
Final Chinese translations mean "final". Java can be used to modify classes, methods, variables, and method parameters.
Class
The final modified class cannot be inherited, so the Member methods in the final class cannot be overwritten. By default, they are all final. When designing a class, if the class does not need a subclass, the implementation details of the class cannot be changed, and it is sure that the class will not be loaded and extended, it is designed as a final class.
Method
If a method in a class does not allow its subclass to overwrite, you can declare this method as a final method.The compiler transfers the final method to the embedded mechanism to greatly improve the execution efficiency.
Final variable (constant)
The final modified member variable is used to represent constants, and the value cannot be changed once given.
Final Parameters
When the function parameter is of the final type, you can read and use this parameter, but you cannot change the value of this parameter.
Static
Static indicates the meaning of "global" or "static". It is used to modify member variables and member methods.
The static modified member variables and member methods are independent of any object in the class. That is to say, it is shared by all instances of the class and does not depend on a specific instance of the class.
As long as the class is loaded, the Java Virtual Machine can locate the class names in the Method Area of the runtime data zone. Therefore, a static object can be accessed before any of its objects are created without referencing any objects.
The implication is that you can use
"Class Name. Method Name(Parameter list ...)"Or" class name. variable name.
Static and final
Static final is used to modify member variables and member methods. It can be simply understood as "Global constants" and "global methods".
For a variable, it means that once the value is given, it cannot be modified and can be accessed through the class name.
For methods, it means they cannot be overwritten and can be accessed directly by class names.