This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person { | |
private String name; | |
private int age; | |
Person(String name, int age){ | |
this.name = name; | |
this.age = age; | |
} | |
public String getName() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReferenceTest { | |
public static void main(String[] args) { | |
Person person = new Person("Tom Criuse", 44); | |
System.out.println(person.getName()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
Person person = new Person("Tom Criuse", 44); | |
modifyPerson(person); | |
System.out.println(person.getName()); | |
} | |
private static void modifyPerson(Person person) { | |
person.setName("Brad Pit"); |
OlderNewer