Skip to content

Instantly share code, notes, and snippets.

@ahinchman1
Last active April 2, 2018 04:16
Show Gist options
  • Save ahinchman1/513e7fcd70d62dffe1a5276c3049ebcd to your computer and use it in GitHub Desktop.
Save ahinchman1/513e7fcd70d62dffe1a5276c3049ebcd to your computer and use it in GitHub Desktop.
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