Here you can find the source of copyIterator(Iterator
Parameter | Description |
---|---|
iter | a parameter |
public static <T> List<T> copyIterator(Iterator<T> iter)
//package com.java2s; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { /**/*from w w w . ja v a 2 s . c o m*/ * Copies the iterator object into the List(ArrayList) of the specific generic type * @param iter * @return */ public static <T> List<T> copyIterator(Iterator<T> iter) { List<T> copy = new ArrayList<T>(); while (iter.hasNext()) copy.add(iter.next()); return copy; } }