The static or global meaning is used to modify classes, methods, and variables. Usually we hear class members or static variables (that is, they don't change after loading). When a static member is loaded, it will no longer change, such as string strings, once initialized the value will no longer change. Generally in development, we will share members with static modification.
1, the most common is: To modify the member variable (to become a member of the class), e.g.: Program status and exception information. (These two are generally decorated with static and final, which is common in development).
2, used to modify the member method, turn it into a class method, you can use the "type. Method Name" Call, commonly used in tool classes. (That is, you do not need to create objects)
3, static code block, on the initialization of multiple objects (static code block is executed earlier, only after the static variable)
static variables
Next we talk about the difference between static variables (modified by static) and instance variables (not modified by static variables):
1, static variables: In memory is just a copy, only initialized once, only once memory, with the type can be directly accessed, you can also create objects to access.
2, instance variables: Called to create an object, not created once to allocate memory once, in memory can have multiple tests, but do not affect each other.
Static methods
A static method can be called directly from a class name, or it can be called directly by an instance. So the super and the This keyword cannot exist in a static method (if there is not the same as bullying?). An instance variable is associated with a specific object).