Last active
January 3, 2018 20:02
-
-
Save gpltaylor/b7b839e2076136c91d0c5ba7a0748e42 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
import java.util.ArrayList; | |
class Person { | |
private String name; | |
public Person(String name) { | |
setName(name); | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String toString() { | |
return name; | |
} | |
} | |
public class MyClass { | |
public static void main(String args[]) { | |
java.util.List<Person> myList = new ArrayList<Person>(); | |
myList.add(new Person("bob")); | |
myList.add(new Person("john")); | |
myList.add(new Person("carl")); | |
Person person = myList.get(1); | |
person.setName("Adam"); | |
System.out.println("Sum of x+y = " + myList); | |
//myList.set(1, "Steve"); | |
System.out.println("Sum of x+y = " + myList); | |
System.out.println("person: " + person ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment