-
Final
The FIANL keyword can decorate classes, methods, and variables.
A. Modifier classes
The final decorated class, which has no subclasses and cannot be inherited by the class.
B. Modification methods
Final can modify the method. The final decorated method cannot be overridden.
c. modifier variables
The final modified variable, which is a constant and can only be assigned once, is a member variable and a local variable.
-
Static
A. Static is used to decorate members, which can be member variables and member methods.
B. Members that are modified by static can be called directly by the class. Class name. Static member
C. Loads as the class loads and disappears as the class disappears. When a class is loaded, there is a static member that exists before the object. The static member life cycle is long.
D. be shared by all objects.
E. Static variables (that is, class variables) exist in the method area, and non-static variables (instance objects) exist in heap memory.
F. Static methods can only invoke static members. (because static members take precedence over object existence, non-static members do not exist when static methods are generated, so non-static cannot be called)
G. The This super keyword cannot be used in a static method. Because this super represents an object, the object does not yet exist.
H. Static advantage: Save space by storing the shared data of the object in a separate space. Disadvantages, the life cycle is too long, access has limitations.
This article is from the "Sima" blog, make sure to keep this source http://9274590.blog.51cto.com/9264590/1695658
Description of final and static keywords in Java