Call stack or Runtime stack

For every thread JVM will create a separate stack, all method calls performed by thread will be stored in that stack. Each entry in the stack is called one Stack Frame. To represent Stack Frame in Java we use a class called ‘StackTraceElement‘. After completing every method call JVM removes the corresponding entries from the stack. After completing all method calls JVM destroys the empty stack and terminates the program normally. Below is an example program to demonstrate call stack.

RuntimeStackExample :

Runtime Stack/ Call Stack

Call Stack or Runtime Stack

For every thread JVM will create a separate stack, all method calls performed by thread will be stored in that stack. Each entry in the stack is called one Stack Frame. To represent Stack Frame in Java we use a class called ‘StackTraceElement‘. After completing every method call JVM removes the corresponding entries from the stack. After completing all method calls JVM destroys the empty stack and terminates the program normally. Below is an example program to demonstrate call stack.

RuntimeStackExample :

Runtime Stack/ Call Stack

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top