public class Main { public static void main(String args[]) { trace(Thread.currentThread().getStackTrace()); } public static void trace(StackTraceElement e[]) { boolean doNext = false; for (StackTraceElement s : e) { if (doNext) { System.out.println(s.getMethodName()); return; } doNext = s.getMethodName().equals("getStackTrace"); } } }