Home > Back-end >  Simple basic understanding (1) - Java
Simple basic understanding (1) - Java

Time:12-21

memory structure:
Stack memory: used to store a local variable, when the data is used up, what occupy a space will be automatically released and be gc recycling,
Heap memory: array and object, member variables, established through new instances are stored in a heap memory,
Methods area: static members, a constructor, constant pool, pool


Local variables:
Stored in the stack, the variables in the class method,
Scope: within the method
Life cycle: the method was performed,
Is modified, the only final,
: when using should be displayed their assignment,
When local variables and members of the same name, local variables when using higher priority, then need to use member variables on this visit,


Members of the (global) variables:
Stored in the heap, the variables in the class, the static modifier is a static variable (class), no static modification is the instance variable
Scope: class in the class or permissions allow external can also use the
Life cycle:
Static variables: during the running of the whole program
Real variables: the object's lifetime
Is modified, the public, pravite, static, final, etc.
Use: when being loaded or is instantiated, the system will allocate memory, to the default values, basic types of the default is 0, such as int, composite type defaults to null
Such as Integer