开发者

Memory allocation in java

开发者 https://www.devze.com 2022-12-27 01:03 出处:网络
class Someobject { int i=10; } public class OtherObject { public static vo开发者_Go百科id main(String args[])
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

精彩评论

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

关注公众号