1. Static member variable 1.1 can be called either with the object name or directly with the class name to call person.i = 10; Person is a class name. I is a member variable; a class name. member variable =; The function of a static variable: A variable shared by all instance variables of the same type. Tip: A static variable is initialized before any static methods of the class are executed.
1.2 He is not an object-level variable, it is a class-level variable, it belongs to a class.
2. Static function 2.1 function in front of the static keyword, can be called directly with the class name; 2.2 Because this is not available, soa static function cannot reference a non-static variable.
Tip: Static methods cannot invoke non-static variables/methods. Because a static method is called by the name of the class, a static method cannot refer to any instance variable of the class. Static method calls have no objects. 3. Static code block he has no name. is to execute itself when loading the class, assigning the initial value to the static member variable, using less. A starter program suitable for putting static final variables. static{The code is ..... }
4.final1. A variable marked as final indicates that it will not be altered once it has been initialized. Constants in 2.java are defined as public static final double PI = 3.14 constant names should all be uppercase letters. 3.final is not only used on static variables, it can also be used to modify non-static variables. A final variable represents a method that cannot change the final value to represent a class that cannot override the final.
From for notes (Wiz)
6.static, Final keywords