r/javahelp • u/Alternative_Ad_8288 • 8d 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.
View all comments
6
u/Jamarlie 8d ago
Two tips here from someone who has also taught a few courses on basic programming:
If I have an array of length 3, then I know at compile-time that my array will be 3. So that goes on the stack. If I ask the user for input, I have no way to know how much input the user gives me until he has given me his input. That is a dynamic allocation that belongs on the heap. That's all you really need to know for now, I feel like getting into the thick of it will only hurt you at this stage.