import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class StudentDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
Collection stu =new ArrayList();
Student s1 = new Student(26,"李宗仁");
stu.add("s1");
Student s2 = new Student(25,"白崇禧");
stu.add("s2");
Student s3 = new Student(24,"黄绍宏");
stu.add("s3");
Iterator it=stu.iterator();
while(it.hasNext())
{
Student s = (Student) it.next();
System.out.println(s.getAge());
}
}
} |
|