迭代器简易用法Iterator

 1 public static void main(String[] args) {
 2         List<String> list = Arrays.asList("111","222","111","333","4444");
 3         Collections.reverse(list);
 4         System.out.println(list);
 5         Iterator<String> iterator = list.iterator();
 6         while (iterator.hasNext()) {
 7             String str = iterator.next();
 8             System.out.println(str);
 9         }
10     }

 

posted @ 2022-01-10 18:01  yoyo17  阅读(32)  评论(0编辑  收藏  举报