本文介绍了为什么我不能通过学生集合进行迭代?请帮忙。谢谢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ArrayList<studentinfo> students = new ArrayList<studentinfo>();
StudentInfo student = new StudentInfo();
//1
student.studentName = "Justin Lazaro";
students.add(student);
student.barrowedBooks = ("English, Math");
//add to list
//2
student = new StudentInfo();
student.studentName = "Gian Acuna";
student.barrowedBooks = "Math";
students.add(student);
//etc.
//further...
// use for(...) loop
// to iterate through the collection of student
Iterator itr = student.iterator();
while (itr.hasNext()){
System.out.println(itr.next());
}
推荐答案
这篇关于为什么我不能通过学生集合进行迭代?请帮忙。谢谢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!