我是靠谱客的博主 重要飞机,这篇文章主要介绍遍历数组、集合的三种方式,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int [] array = new int[]{2,3,4,5,6,8}; //普通for循环 for (int i = 0; i < array.length; i++) { System.out.println(array[i]); } //增强for循环 for (int i : array) { System.out.println(i); } //使用迭代器 List<Integer> list = new ArrayList<Integer>(); list.add(1); list.add(3); Iterator<Integer> iterator = list.iterator(); while (iterator.hasNext()) { Integer i = iterator.next(); System.out.println(i); }

 

转载于:https://www.cnblogs.com/codeXi/p/11221560.html

最后

以上就是重要飞机最近收集整理的关于遍历数组、集合的三种方式的全部内容,更多相关遍历数组、集合内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(75)

评论列表共有 0 条评论

立即
投稿
返回
顶部