// Zorah Fung // This program illustrates "Value Semantics" // When we pass primitive types (e.g. int, double) we pass a *copy* // of the value to the method. public class ValueSemantics { public static void main(String[] args) { int x = 23; System.out.println("1. x = " + x); strange(x); // Passing the value of (x) not the variable itself System.out.println("3. x = " + x); // x = 23 } public static void strange(int x) { x = x + 1; // Modify parameter x System.out.println("2. x = " + x); } } /* whatever I want */