Home > Back-end > Java instance variables are stored in a heap area or stack area?
Java instance variables are stored in a heap area or stack area?
Time:12-31
I know local variables are stored in the stack area, but the instance variables (including my master data types) to store where, stack area? Or heap area? , that reference variables? In asking god taught!!!!!
CodePudding user response:
Object on the heap, stack save values of basic types, object reference (which can be understood as object on the heap of address).
CodePudding user response:
All the instance variables and reference variables, and so on are in the stack memory (both instance and are the object of the deposit of the corresponding address, rather than the object itself). The object itself as well as the object of data members in the heap memory.
CodePudding user response:
Objects in the heap, a local variable object in the heap, a local variable is only reference
CodePudding user response:
Object itself is in a heap, quoted in the stack, stack operation is actually a method invocation, corresponds to the stack frame into and out of the stack
CodePudding user response:
Reference type variables can also be a local variables, local variables stored in the stack area, but it the referenced object stored in the heap or constant pool,
Member variables of an object, that is, you're an instance variable, with the object, the object in the heap, so it is also in the heap,