/**
 * Outputs a stack trace when the call stack is three levels deep. 
 * 
 * When h executes, the call stack looks like this:
 * 
 *    ╔═════════════════════════════╗
 *    ║ stack frame for method g
 *    ║ stack frame for method f
 *    ║ stack frame for main method
 *    ╚═════════════════════════════╝ 
 *
 * @author Drue Coles
 */
public class StackTraceDemo {

    public static void main(String[] args) {
        f();
    }

    private static void f() {
        g();
    }

    private static void g() {
        h();
    }

    private static void h() {
        StackTraceElement[] elements = Thread.currentThread().getStackTrace();
        for (StackTraceElement elem : elements) {
            System.out.println(elem);
        }
    }
}