I am learning java and right now
i am stuck at memory allocation of object’s and local variables.
can any one illustrate or clear some of my doubts??
- I read about Heap and Stack Memory for Object’s instance
Variable’s and Local Variable’s. I have question whether a new
STACK is being created for each method?? or for each class of a
single stack is used by a whole class?? - I had read that ONE STACK
is being created by every thread What is means
Thanks
Mahaveer
Stacks are associated with thread in a one-to-one mapping. Stacks are absolutely not associated with methods and classes.
The way to reason about all this is that the local variables of a method are private to each invocation of that method.