If you've just started learning Java, you've probably heard something like this:

"Primitive variables are stored on the Stack, and Objects are stored on the Heap."

While this is a useful starting point, it's also one of the biggest sources of confusion for Java developers.

The real concept you need to understand isn't Stack vs Heap.

It's Values vs References.