Java variable placed on stack or heap

后端 未结 3 1612
醉酒成梦
醉酒成梦 2020-12-01 04:18

I don\'t have much idea on Java.

I was going through few links and found blog says \"Java Primitives stored on stack\", which I feel it depends on instance variable

3条回答
  •  猫巷女王i
    2020-12-01 05:00

    Object are stored in the Heap.

    The object reference stored in the stack.

    Static variable stored in the method area.

    Example

    abc obj=new abc();
    

    abc object save in the heap and the object reference is stored in the stack.

      static int i=10;
    

    i variable stored in the method area.

提交回复
热议问题