Members and local variables difference
Variable according to
different definitions of position,
we have to play a different variable names. As shown below:
the difference
Different positions in the class
- Member variables: class, method outside
- Local variables: the method or the method declaration (formal parameters), the parameters in the method call will certainly be assigned
Scope is not the same
- Member variables: class
- Local variables : the method
Different initialization values
- Member variable: there are defaults
- Local variables : no default. You must define, assign, and finally use
Different locations in memory
- Member variables : heap memory
- Local variables: Stack Memory
Different life cycle
- Member variables : With the creation of the object exists, the object disappear with the disappearance
- Local variables : With call a method exists, along with the method call is completed disappear