Search code examples
javaheap-memoryramstack-memory

Does both Heap and Stack of Java reside in RAM, similar to C++?


This question is not about difference between Stack and Heap in Java. In C++, both Stack and Heap are in RAM. How is it in Java?


Solution

  • Yes. Stack is used for static memory allocation and Heap for dynamic memory allocation, both stored in the computer's RAM

    This is to ensure faster processing of java programs.