/* Java application that illustrates how flow-of-control (i.e., the order in ** which the statements in a program are executed) is influenced by calls to ** methods. */ public class FlowOfControl { public static void main(String[] args) { System.out.println("Starting main()."); // M1 System.out.println("About to call method1()."); // M2 method1(); // M3 System.out.println("Inside main(); back from method1()."); // M4 System.out.println("About to call method2()."); // M5 method2(); // M6 System.out.println("Inside main(); back from method2()."); // M7 System.out.println("Ending main()."); // M8 } private static void method1() { System.out.println("Starting method1()."); // 1.1 } private static void method2() { System.out.println("Starting method2()."); // 2.1 System.out.println("About to call method1()."); // 2.2 method1(); // 2.3 System.out.println("Inside method2(); back from method1()."); // 2.4 System.out.println("About to call method1() a second time!."); // 2.5 method1(); // 2.6 System.out.print("Inside method2(); "); // 2.7 System.out.println(" back from 2nd call to method1()."); // 2.8 } }