两种遍历List的方式
来源:互联网 发布:三角木马淘宝 编辑:程序博客网 时间:2024/06/06 10:19
遍历List集合中的元素的方法有两种:
第一种:利用迭代器遍历
itertor即枚举器,枚举器是Java在后台自动排序好,比纯粹的for循环要快
第一种代码
// 迭代器 Iterator it=list.iterator(); while(it.hasNext()) { System.out.println(it.next()); }第二种代码
// 迭代器for(Iterator it=list.iterator();it.hasNext();) { System.out.println(it.next());第二种:通过List下标遍历// 像遍历数组一样遍历List for(int i=0;i<list.size();i++) { System.out.println(list.get(i)); }
阅读全文
0 0
- 遍历List的两种方式
- List的两种遍历方式
- 两种遍历List的方式
- [List]——两种遍历方式
- list的四种遍历方式,遍历list集合
- List的遍历方式
- HashMap遍历的两种方式
- 遍历数组的两种方式
- 遍历HashMap的常用两种方式
- HashMap遍历的两种方式
- HashMap遍历的两种方式
- HashMap遍历的两种方式
- HashMap遍历的两种方式
- hashmap遍历的两种方式
- HashMap遍历的两种方式
- HashMap遍历的两种方式
- 遍历HashMap的两种方式
- HashMap遍历的两种方式
- linux 技巧:使用 screen 管理你的远程会话
- 深入浅出AQS之条件队列
- 警告: Exception encountered during context initialization
- hdu1024 Max Sum Plus Plus
- RIAD工作原理
- 两种遍历List的方式
- JAVA语言是值传递还是引用传递
- OpenStack--网络环境实践(一)
- OpenStack--网络环境实践(二)
- 51nod 1366 贫富差距(最短路)
- rapidjson解析json代码实例以及常见的json core dump问题
- poj 2391 Ombrophobic Bovines
- Android移动开发-调用摄像头进行拍照的实现
- 第十五课 插入数据