Originally posted by Kamal Trivedi:
Stack stores non-static variables & Heap stores Object's
1) Where do Stack & Heap are ? in terms of Hardware ie in RAM or Cache ?
2) How Heap is faster then Stack ?
3) Where does static variable store ? In RAM or Cache Memory or any registers ?
The stack is for local variables. The heap is for objects. (with
Java 6 and later, this changes somewhat, but that will just confuse stuff)
1. The stack and heap are just in different memory areas. In terms of hardware, they use the same hardware.
2. Well, maybe one is faster, as they are likely to use different machine instructions. And implementation is different, but...
3. As mentioned. Same hardware. Just different areas of memory.
Henry