I want to dive deeper into internals of object creation and storing. Any guidance?

hey guys. I decided to deepen my knowledge about how objects are created and stored. so im reading Java: The complete reference and i found this piece of code
Box mybox; // declare reference to object
mybox = new Box(); // allocate a Box object
Box mybox; // declare reference to object
mybox = new Box(); // allocate a Box object
and i was wondering, how can i peek into the place where objects are stored? i want to get/dive deeper into internals but idk how. any help? thanks!
5 Replies
JavaBot
JavaBot12mo ago
This post has been reserved for your question.
Hey @bambyzas! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
noComment | Kez
noComment | Kez12mo ago
Baeldung
Stack Memory and Heap Space in Java | Baeldung
Explore how Stack Memory and Heap Space works and when to use them for developing better Java programs.
noComment | Kez
noComment | Kez12mo ago
Or what do you mean by "the place where objcts are stored"?
tjoener
tjoener12mo ago
All non primitive types in Java are stored on the heap (there is an exception for a specific optimization in which it sometimes doesn't, but let's ignore that for now) So that means everything that extends Object (this includes arrays, even arrays of primitive types), will be allocated on the heap If you hold a reference to an object (in the little example above, mybox), that's an actual pointer, that's a value that lives on the stack
JavaBot
JavaBot12mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server