Java uses a stack to keep track of the sequence of method calls within a program. This approach can be used to trace recursive methods by hand. (The technique actually works for any sequence of method calls though it is usually only worthwhile for recursive methods.)
Stack based recursive method tracing technique
- Place the first method call in an empty stack.
- When a recursive call is made note the position at which the calling method stopped and add the called method to the top of the stack.
- When a method returns note the return value, cross out the method and return to the position at which the top most method in the stack stopped.