开发者

Where instance variables(primitives) are stored in java? Is anyhow stack related to instance variables storage?

Where instance variables(primitives) are开发者_运维问答 stored in java?


Primitive variables are stored in the same places all variables are stored (including references):

  • Within objects created (allocated) on the heap, or
  • Within method stack frames as local variables, or
  • Within static areas of their containing class (which are on the heap).


If you mean instance fields declared on a class, they are allocated on the heap as part of the object's own allocation.

Primitive (value type) variables declared as method locals are stored in the method's stack frame.


After class loader loads classes with qualified name into the jvm . JVM parse the binary data from the class and place that info into the Method area. When JVM executes the class it first place the Objects (including instance fields primitive/non primitive) into the heap.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜