Here you can find the source of appendTo(final Iterator
Parameter | Description |
---|---|
iter | the iterator |
list | the list |
public static <T> void appendTo(final Iterator<T> iter, final List<T> list)
//package com.java2s; //License from project: Apache License import java.util.Iterator; import java.util.List; public class Main { /**//from ww w. ja va 2s . c o m * Appends all elements which the iterator is willing to produce to the * given list. * * @param iter * the iterator * @param list * the list */ public static <T> void appendTo(final Iterator<T> iter, final List<T> list) { assert null != iter; assert null != list; while (iter.hasNext()) { list.add(iter.next()); } } }