Where does java reference variable stored?

前端 未结 6 665
醉话见心
醉话见心 2020-12-06 02:29

How does Java\'s reference variable stored? Is that work similar to C pointer?

what I mean by reference variable is myDog in this code

Dog myDog = ne         


        
6条回答
  •  执笔经年
    2020-12-06 03:05

    All the references to s1, s2, ob1, obj2 and obj3 will be stored in the Stack.

    The objects data, will be stored in the Heap (and for String for example in can be stored in a special constant pool).

提交回复
热议问题