import java.util.Scanner; /** * This class illustrates that a parameter variable gets the initial * value from the argument passed in, however, changes made in the * method DO NOT AFFECT the original variable passed in. */ public class PassByValue { /** * */ public static void main(String[] args) { System.out.println("Hello from main (before method call)"); Scanner sc = new Scanner(System.in); int mynum = sc.nextInt(); displayInt(mynum); System.out.println("In main, returned from method displayInt." + " mynum=" + mynum); } /** * displayInt displays the value of the parameter to the screen * @param num the number to display to the screen */ public static void displayInt(int num) { System.out.println(num); num++; System.out.println("in method, num = " + num); } }