The difference between static variables and non-static variables in java

The difference between static variables and non-static variables is as follows: Memory allocation A static variable exists in memory when the application is initialized, and does not die until the program of the class it is running ends. Memory is not allocated until a static variable needs to be instantiated. 2. Life cycle The static variable life cycle is the existence period of the application; The existence period of a non-static variable depends on the existence period of the instantiated class. 3. Calling method Static variables can only be called by "class.static variable name", and instances of the class cannot be called; Non-static variables can be accessed directly through the instantiated class name when the class in which the variable is located is instantiated. 4. Sharing method Static variables are global variables that are shared by instance objects of all classes, that is, an instance changes the value of a static variable, and other similar instances read the changed value; Non-static variables are local variables that are not shared. 5. Access method Static members cannot access non-static members; Non-static members can access static members.