Skip to content

Instantly share code, notes, and snippets.

@easternHong
Created September 29, 2014 08:13
Show Gist options
  • Save easternHong/53c79e060a00eceaeac8 to your computer and use it in GitHub Desktop.
Save easternHong/53c79e060a00eceaeac8 to your computer and use it in GitHub Desktop.
sexy
import java.util.ArrayList;
import java.util.Collection;
import java.util.*;
public class ArrayList_LinkedList {
public static final String filePath = "D:/MP";
public static void main(String[] args) {
Collection collection = new ArrayList();
collection.add(new Person("son1 "));
collection.add(new Person("son2 "));
collection.add(new Person("son3 "));
Iterator i = (Iterator) collection.iterator();
while (((java.util.Iterator) i).hasNext()) {
Person pp = (Person) i.next();
System.out.println(pp.getFirstName());
}
}
public static class Person {
private String p1, p2;
private String p3 = "buddy";
public Person(String p1) {
this.p1 = p1;
this.p2 = p1;
}
public String getFirstName() {
return p1;
}
public String getLastname() {
return p2;
}
public String toString() {
return p1 + "" + p2;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment