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
最后
以上就是重要飞机最近收集整理的关于遍历数组、集合的三种方式的全部内容,更多相关遍历数组、集合内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复