Java中如何使用Iterable接口遍历所有元素
作者:WeekendLife
时间:2023-04-29
浏览:1
Iterable接口通过迭代器Iterable来进行遍历集合中的元素:System.out.println("(迭代器)学生信息:");Iteratorit=students.iterator();while(it.hasNext()){Students=(Student)it.next();System.out.println("编号:"+s.ID+"\t\t\t姓名:"+s.name+"\t\t\t年龄:"+s.age+"\t\t\t性别:"+s.gender);}迭代器用来遍历集合中的元素,本身是不
本文目录
Iterable接口
通过迭代器 Iterable 来进行遍历集合中的元素:
System.out.println("(迭代器)学生信息:");
Iterator it=students.iterator();
while(it.hasNext()){
Student s=(Student)it.next();
System.out.println("编号:" + s.ID + "\t\t\t姓名:" + s.name + "\t\t\t年龄:" + s.age + "\t\t\t性别:" + s.gender);
}迭代器用来遍历集合中的元素,本身是不具备有存储能力的,是依赖于集合而存在的。
作者最新文章
漫蛙漫画官方入口
2026-10-13 13:50
漫蛙官网入口免费下载最新版
2026-10-13 13:46
漫蛙网页版入口在哪里
2026-10-13 13:18
漫蛙网页版免费进入
2026-10-13 13:16
漫蛙MANWA网页版登录不迷路
2026-10-13 13:16
上一篇:
Java中TypeToken的用法及示例
热门文章
更多
精品专题
更多
Mac软件
更多
WINDOWS
更多










































