开发者

Memory allocation in java

class Someobject
{
  int i=10;
}

public class OtherObject
{
  public static vo开发者_Go百科id main(String args[])
  {
    Someobject obj=new Someobject();
    System.out.println(obj.i);
  }
}

Please tell me in which section of the memory:

  1. This entire code will load.
  2. Where will someobject will be stored.
  3. Where will obj will be stored
  4. Where will i be stored.

Thanks every one in advance.


  1. The code/classes will load in PermGenSpace
  2. The Objects are created in the HEAP
  3. The obj reference is stored on the stack
  4. i is part of the SomeObject instance which lives in the HEAP.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜