The difference between a static variable and a member variable:
A: Belong to different
Static variables: Belong to class, class variable
Member variables: objects, object variables, instance variables
B: Different memory locations
Static variables: Static area of method area
Member variables: Heap memory
C: Different life cycles
Static variables: Static variables are loaded as classes are loaded, disappearing as classes disappear
Member variables: member variables exist as objects are created and disappear as objects disappear
D: Calling different
Static variables: Can be invoked by object name, or by class name
Member variables: Only called by object name
The difference between a member variable and a local variable:
A: The position in the class is different
Member variables: Outside of methods in a class
Local variables: In the method definition or the method declaration
B: In-memory locations are different
Member variables: in heap memory
Local variables: in stack memory
C: Different life cycles
Member variables: exist as objects are created and disappear as objects disappear
Local variable: exists as a method call and disappears as the method is called
D: Different initialization values
Member variable: has default initialization value
Local variables: There is no default initialization value, you must define, assign, and then use.
Precautions :
Local variable names can be the same as member variable names, when used in a method, using the proximity principle.
The above is a small series for everyone to talk about static variables, member variables, local variables, the difference of all the contents of the three, I hope to help you, a lot of support cloud Habitat Community ~