Contrast member variables and local variables

the difference Member variables Local variables
effect Property description, describing the current class has attributes which Save necessary data during the process running
position Class member variables defined within the braces, among other braces A method within the braces or braces block
The initial value Member variables without assigned construction method, the corresponding data type is "zero" value Unassigned can not participate in other operations in addition to the assignment.
Scope Class member variables stored in the object, in memory of the heap, where the current holders of the class object space first address, scope on where There is one and only current within the braces
Survival Lifetime member variable is created with the class object starts, when the object is destroyed JVM's GC, lifetime member variables of termination From the definition of the start position, the end of the current braces
Released five original articles · won praise 4 · Views 173

Guess you like

Origin blog.csdn.net/qq_40197991/article/details/104469796