JAVA 迭代器的简单使用
时间:2021-09-02 04:24:00
收藏:0
阅读:11
Iterator
Collection<String> coll = new ArrayList<>(); coll.add("a"); coll.add("b"); Iterator<String> it = coll.iterator();//指针指向集合的-1索引 while (it.hasNext()){ System.out.println(it.next());//取出下一个元素并把指针向后移动一位。 }
原文:https://www.cnblogs.com/yinmu/p/15213296.html
评论(0)