← Back to Week 1 Hub

Method Call Stack

Workbook 1c, pp. 109-111 — How Java tracks method calls

Press Next Step to begin the walkthrough.
Step 0 / 8

Source Code

// main method
1public static void main(String[] args) {
2    int a = 4;
3    int b = 9;
4    int result = add(a, b);
5    System.out.println("Result: " + result);
6}
// add method
7public static int add(int x, int y) {
8    int sum = x + y;
9    return sum;
10}
CONSOLE OUTPUT
 

Call Stack

a x (value 4 copied)
b y (value 9 copied)
return value
13
STACK BOTTOM
The call stack tracks which method is currently running
Each method gets its own frame with its own local variables
When a method finishes, its frame is removed and control returns to the caller
← Method Signature Anatomy Method Decomposition →