Reputation: 31
How could we draw the stack and heap diagram of following code:
Ball b1;
Ball b2 = new Ball();
Ball b3 = new Ball();
b1= doThing();
b3 = doThings();
I know call methed (e.g doThing()) will be in stack. how relate b1 (which is in stack to doThing()). should we create an object in heap for them?
Upvotes: 1
Views: 529
Reputation: 4608
All java-ojbect created in heap. If doThing() instantiate Ball then we should create an object in heap for them on diagram.
Upvotes: 1