I understand if the variable contains a reference to an object, the object itself will be on the heap, and the the variable for primitive value will be on the stack, but where will the variable itself be in the memory? Does it matter if the variable contains a reference to primitive or non primitive types to figure out where the variable itself will be kept?
Asked
Active
Viewed 178 times
1 Answers
0
Heap stores the actual objects that are created via the new operator. eg: String s = new String();
Stack memory holds references to heap objects and also for storing value types which are primitive types. The Stack is used to hold the value directly and does not reference the heap.
This is in short where primitives and objects are stored. There is a lot of documentation available but for detailed i would suggest the official documentation.

Technical 101
- 138
- 7