/** for complex objects **/ static void test2() { Person p = new Person("John"); System.out.println("My current name: \t" + p.getName()); String newName = "Michael"; changeName(p, newName); System.out.println("My new name: \t" + p.getName()); } private static void changeName(Person p, String newName) { //p.setName(newName); // line x p = new Person(newName); // line x + 1 }
Log in to post a comment.
Last edit: Duy Dinh 2014-04-16