Created
September 29, 2014 08:13
-
-
Save easternHong/53c79e060a00eceaeac8 to your computer and use it in GitHub Desktop.
sexy
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; | |
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