Java Collection Add addAll(Collection collection, Iterable items)

Here you can find the source of addAll(Collection collection, Iterable items)

Description

Add all the items from an iterable to a collection.

License

Open Source License

Parameter

Parameter Description
T The type of items in the iterable and the collection
collection The collection to which the items should be added.
items The items to add to the collection.

Declaration

public static <T> void addAll(Collection<T> collection,
        Iterable<? extends T> items) 

Method Source Code

//package com.java2s;

import java.util.Collection;

public class Main {
    /**//  w w w  .  j a v  a2 s  . co  m
     * Add all the items from an iterable to a collection.
     *
     * @param <T>
     *          The type of items in the iterable and the collection
     * @param collection
     *          The collection to which the items should be added.
     * @param items
     *          The items to add to the collection.
     */
    public static <T> void addAll(Collection<T> collection,
            Iterable<? extends T> items) {
        for (T item : items) {
            collection.add(item);
        }
    }
}

Related

  1. addAll(Collection c, T[] a)
  2. addAll(Collection col, T[] arr)
  3. addAll(Collection coll, T... elems)
  4. addAll(Collection coll1, Collection coll2)
  5. addAll(Collection collection, Collection toAdd)
  6. addAll(Collection collection, T... array)
  7. addAll(Collection collection, T... elementsToAdd)
  8. addAll(Collection collection, T... elementsToAdd)
  9. addAll(Collection collection, T... newElements)