黑马程序员技术交流社区
标题:
三种遍历方式 ,轻松掌握!还有的大神们继续补充。。。
[打印本页]
作者:
MoonsenHung
时间:
2015-8-19 12:07
标题:
三种遍历方式 ,轻松掌握!还有的大神们继续补充。。。
Iterator<Student> it = array.iterator();//迭代器
while (it.hasNext()) {
Student s = it.next();
System.out.println(s.getName() + "***" + s.getAge());
}
System.out.println("------------------");
//普通for
for (int x = 0; x < array.size(); x++) { Student s = array.get(x);
System.out.println(s.getName() + "***" + s.getAge());
}
System.out.println("------------------");
// 增强for
for (Student s : array) {//增强for
System.out.println(s.getName() + "***" + s.getAge());
}
作者:
MoonsenHung
时间:
2015-8-19 15:36
大神们,冲冲冲,顶一下先,沉下去了,,,
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2