/* Method5.java CIS 160 Dave Klick 2004-10-18 passing reference variables */ class MyNum { public int n; } public class Method5 { public static void main(String[] args) { MyNum obj = new MyNum(); obj.n = 5; System.out.println("Before calling changeNum(): " + obj.n); changeNum(obj); System.out.println("After calling changeNum(): " + obj.n); } private static void changeNum(MyNum o) { System.out.println("Start of changeNum(): " + o.n); o.n = 7; System.out.println("End of changeNum(): " + o.n); } } /* Output: Before calling changeNum(): 5 Start of changeNum(): 5 End of changeNum(): 7 After calling changeNum(): 7 */