Last active
April 2, 2018 04:16
-
-
Save ahinchman1/513e7fcd70d62dffe1a5276c3049ebcd to your computer and use it in GitHub Desktop.
This file contains 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 { | |
// instance variables | |
String firstName; | |
String lastName; | |
int age; | |
// constructor | |
public Person(String firstName, String lastName, int age) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.age = age; | |
} | |
// getters and setters | |
... | |
public static void main(String args[]) { | |
Person person = new Person("Jane", "Trin", 35); | |
Person twin = person; | |
twin.setFirstName("Steve"); | |
// set Steve's age | |
twin.setAge(40); | |
// set Jane's age | |
person.setAge(30); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment