/** * This class shows what happens when a method calls another method. * * @author alchambers * @version spring2019 */ public class MethodExecution{ private static void method2(double fValue, int iValue, boolean status, String phrase){ System.out.println("\tMethod2: " + fValue + " " + iValue + " " + status + " " + phrase); fValue = fValue / 5.0; iValue = iValue / 2; phrase = phrase + "!"; System.out.println("\tMethod2: " + fValue + " " + iValue + " " + status + " " + phrase); return; } private static void method1(double fValue, int iValue, boolean status, String phrase){ System.out.println("\tMethod1: " + fValue + " " + iValue + " " + status + " " + phrase); fValue = fValue + 1; iValue = iValue - 1; phrase = phrase + " with a chainsaw"; System.out.println("\tMethod1: " + fValue + " " + iValue + " " + status + " " + phrase); method2(fValue, iValue, status, phrase); System.out.println("\tMethod1: " + fValue + " " + iValue + " " + status + " " + phrase); } public static void main(){ // In this first example, literal values are passed to method1() System.out.println("Main: 44.0, -14, true, \"Enchantress of Numbers\""); method1(44.0, -14, true, "Enchantress of Numbers"); // In this second example, variables are passed to method1() double fValue = 5.0; int iValue = -100; boolean status = false; String phrase = "Everything I Never Told You"; System.out.println("Main: " + fValue + ", " + iValue + ", " + status + ", " + phrase); method1(fValue, iValue, status, phrase); System.out.println("Main: " + fValue + ", " + iValue + ", " + status + ", " + phrase); } }