Java Collection Add addToCollection(Iterator iterator, Collection collection)

Here you can find the source of addToCollection(Iterator iterator, Collection collection)

Description

add To Collection

License

Open Source License

Declaration

private static <T> Collection<T> addToCollection(Iterator<T> iterator, Collection<T> collection) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;
import java.util.Collections;

import java.util.Iterator;

public class Main {
    private static <T> Collection<T> addToCollection(Iterator<T> iterator, Collection<T> collection) {
        while (iterator.hasNext()) {
            T object = iterator.next();/*from  w  w w. jav a  2s .  co  m*/
            collection.add(object);
        }
        return Collections.unmodifiableCollection(collection);
    }
}

Related

  1. addTo(Map> map, K key, V value)
  2. addToCollection(C collection, E... elements)
  3. addToCollection(Collection collection, final T value)
  4. addToCollection(Collection collection, T obj)
  5. addToCollection(Collection theCollection, T... objects)
  6. addToCollection(T dest, boolean failOnNull, Iterable... srcs)
  7. addToCollectionIfNotNull(Collection collection, Object value)
  8. addToString(final Collection output, final T element, final boolean stringifyNull)
  9. appendToCollection(Collection col, String str)