The stack stores method call frames and local variables.
In Java, each thread has its own stack, which holds frames for method calls. Each frame contains local variables and partial results. When a method is invoked, a new frame is created on top of the stack. Once the method execution is completed, the frame is popped off, and its memory is instantly reclaimed. For example, in a method calculating the sum of two numbers, the local variables storing the numbers and result are on the stack.
Additional Notes
Why does the stack in Java memory management matter in practice?