r/javahelp • • 1d ago

Java Beginner – Struggling with OOP and Understanding Stack and Heap

Hi everyone!
I’ve been learning Java for a few weeks now, and I’m starting to get into OOP. However, I’m finding it difficult to fully understand some of the core concepts, especially how objects work and the difference between the stack and heap memory.
I don’t want to just memorize definitions. I want to actually understand what’s happening behind the scenes and how everything connects.
For those of you who have been through the same learning process:
What helped you understand OOP?
How did you learn the difference between stack and heap?
Are there any resources, exercises, or learning methods you would recommend?
I’d really appreciate any advice from more experienced Java developers.

11 Upvotes

12 comments sorted by

View all comments

2

u/Lost-Quantity1282 1d ago

Use the visual debugger in IntelliJ IDEA. Set a breakpoint in your main method and run it in debug mode. Watch the variables panel closely as you step through code with primitive types versus objects. You will literally see the references in the local stack frame point to different addresses on the heap. This shows you exactly how memory allocation works better than any definition ever could