System.out.println(st.toString());
這相當於壹個foreach語句~是jdk1.5以上的版本才有的
相當於
for(int i=0;i<students.size();i++){
Student st = (Student)students.get(i);
System.out.println(st.toString());
}
或者用叠代其也可以實現:
Iterator it = students.iterator();
while(it.hasNext()){
Student st = (Student)it.next();
System.out.println(st);
}