package com.itheima_76;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ListTest {
public static void main(String[] args) {
List<Student> list = new ArrayList<Student>();
Student s1 = new Student("王昱翔",35);
Student s2 = new Student("黄文平",33);
Student s3 = new Student("王鑫",24);
list.add(s1);
list.add(s2);
list.add(s3);
for(int i = 0;i < list.size(); i++){
Student s = list.get(i);
System.out.println("姓名:"+s.getName() +","+"年龄:"+ s.getAge());
}
Iterator<Student> it = list.iterator();
while (it.hasNext()){
Student s = it.next();
System.out.println(s.getName() + s.getAge());
}
}
}