Iterator<String> stringIterator = new ArrayList<>(Arrays.asList("a", "b", "c")).iterator();
//使用while循环将Iterator转换成List
List<String> list = new ArrayList<>();
while (stringIterator.hasNext()) {
list.add(stringIterator.next());
}
2 forEachRemaining()
Iterator<String> stringIterator = new ArrayList<>(Arrays.asList("a", "b", "c")).iterator();
//使用forEachRemaining()将Iterator转换成List
List<String> list1 = new ArrayList<>();
stringIterator.forEachRemaining(list1::add);
3 StreamSupport.stream()
Iterator<String> stringIterator = new ArrayList<>(Arrays.asList("a", "b", "c")).iterator();
1 while循环 Iterator<String> stringIterator = new ArrayList<>(Arrays.asList("a", "b", "c")).iterator(); //使用while循环将Iterator转换成List List<String> list = new ArrayList<>(); while (stringIterator.hasNext