/** * Silly class to illustrate the stack of methods in Java * @author GTowell * Created: Feb 18, 2020 */ public class MethodStacker { /** * calls b and then increments * @param ai an integer * @return */ public int a(int ai) { ai = b(ai)+1; return ai; } /** * Calls c then increments * @param bi an integer * @return */ private int b(int bi) { bi=c(bi)+1; return bi; } /** * Increments and dumps the Stack * @param ci an integer * @return */ private int c(int ci) { ci=ci+1; Thread.dumpStack(); return ci; } public static void main(String[] args) { MethodStacker ms = new MethodStacker(); System.out.println(ms.a(5)); } }