Static can modify variables, methods, or classes (ordinary classes cannot be modified with static and can only be used to decorate inner classes)
Static variables are also called class variables (and the concept of global variables in C + + is the same), after a class is loaded, the JVM allocates only one memory for the class variable, and the static variable can be accessed directly from the class name (and, of course, through the instance object), and the static variable corresponds to the instance variable. Each time the object is instantiated, there is a copy in memory, so multiple copies of the instance variable can exist in memory.
static int a=10;
String b= "ABC";
Static Object O=new object ();
Static static methods, also known as class methods (which correspond to instance methods), can only access static variables of the class, and cannot access the instance variables of the class "The non-static member variable does not exist at this time (he was created with the creation of the object) and cannot be accessed at all."
Static BLOCK: A module similar to static{code}, which is executed first when the class is loaded.
Final can modify a variable, either a method or a class
Once the final variable is initialized, it cannot be modified, and the final variable has its value defined at compile time (limited to the basic data type), so you can define some of the already defined values as final to reduce the burden on the runtime. If the non-basic data type is final decorated, then final is the reference, but the properties inside the object can be changed.
Final method, the final method cannot be overridden, so you can lock a method with final to prevent subclasses from inheriting the modification. In addition, the final method is similar to C + + inline functions, which can improve execution efficiency (but this approach sacrifices space and does not recommend a large number of final methods).
The final decorated class is not allowed to be inherited (in final, the method is final by default), and if you do not want a class to be inherited, you can change the class to final.
Java keyword static and final