In this case refA is on stack, while object ClassA is on heap. Variable i is on stack, but does its value 10 is on heap or stack ? If its on stack, then it means variable and its value both are on stack for primitive, right ? What I mean to ask is, in case of object, instance reference variable is on stack, but object is on the heap. Likewise, in case of primitive, primitive reference is on stack, but des it value go on stack or heap (which is 10 for i and 20 for j in this case).
I went through various threads, but could not find clear answer to this.
Can someone please answer this without pointing to different
thread ?
Thanks