Here you can find the source of addAll(Iterator
Parameter | Description |
---|---|
T | a parameter |
U | a parameter |
source | a parameter |
target | a parameter |
public static <T, U extends Collection<T>> U addAll(Iterator<T> source, U target)
//package com.java2s; // License & terms of use: http://www.unicode.org/copyright.html#License import java.util.Collection; import java.util.Iterator; public class Main { /**/* www. j a v a 2s . co m*/ * Add all items in iterator to target collection * @param <T> * @param <U> * @param source * @param target * @return */ public static <T, U extends Collection<T>> U addAll(Iterator<T> source, U target) { while (source.hasNext()) { target.add(source.next()); } return target; // for chaining } }