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:
- This entire code will load.
- Where will
someobject
will be stored. - Where will
obj
will be stored - Where will
i
be stored.
Thanks every one in advance.
- The code/classes will load in PermGenSpace
- The Objects are created in the HEAP
- The obj reference is stored on the stack
i
is part of the SomeObject instance which lives in the HEAP.
精彩评论