r/javahelp • u/Alternative_Ad_8288 • 10d 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
Show parent comment
2
u/Reasonable-Pay-8771 9d ago edited 9d ago
^^ This ^^
Unless you're getting into the JVM and compiler and the byte-code and stuff, Java really hides all this from you (viz. stack vs heap).
OOP is a problematic abstraction because it abstracts away the details of a computer by making it look like a computer. Like if you watch old Alan Kay videos you get the idea. An object = data + functions that operate on that data (which basically is just what a computer already is). And then you have add all the doodads on to get actual abstracting power: inheritance, polymorphism, modules (which kinda turn out to be maybe what objects ought to have been from the beginning).
I'd recommend watching at least one old Alan Kay keynote or something, and then a handful of prefaces from some 80s OO books and that should give you a pretty good grounding. But then, every OO language or implementation is going to have its own special ideas of how it all should work. So if you're going for Java, then don't dwell too long on Alan Kay or any other non-Java-focused OO description because it may or may not be relevant to how Java does it or how you're likely to do it in Java.