import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Created by cuboo on 2016/9/28.
*/
public class iterator {
public static void main(String agrs[]){
List<String> list = new ArrayList<String>();
list.add("A");
list.add("B");
list.add("C");
list.add("A");
for (String s: list) {
System.out.println("ArrayList:"+s);
}
Iterator<String> iterator = list.iterator();
while (iterator.hasNext()){
System.out.println(iterator.next());
}
}
}
Java中Iterator的使用
最新推荐文章于 2021-11-24 15:11:41 发布