标签:each number code tor import integer 迭代 ext next
import java.util.ArrayList;
三种遍历方法:
// 迭代器
import java.util.Iterator;
Iterator<Integer> it = arrayList.iterator();
while(it.hasNext()){
System.out.print(it.next() + " ");
}
// 索引值
for(int i = 0; i < arrayList.size(); i++){
System.out.print(arrayList.get(i) + " ");
}
// for-each
for(Integer number : arrayList){
System.out.print(number + " ");
}
标签:each number code tor import integer 迭代 ext next
原文地址:https://www.cnblogs.com/391halsey/p/12909693.html