I know that local variables and paramters of methods live in stack, but I not able to figure out where does actually methods live in case of Java?
If I declare any T
If I remember correctly, the method code itself will live in the code portion of memory, while the variables declared internally will live in the stack, and the objects will be created on the heap. In Java, the variable pointers and primitives live on the stack, while any created objects live in the heap.
For a (poor) ASCII representation:
-------
|STACK|
-------
|FREE |
-------
|HEAP |
-------
|CODE |
-------
Where the STACK represents the stack, FREE represents free memory, HEAP represents the heap, and CODE represents the code space.
This is what my memory says - some of the details might be wrong.