Java Collection Add addAll(Collection collection, T... elementsToAdd)

Here you can find the source of addAll(Collection collection, T... elementsToAdd)

Description

Adds all elements to the Collection .

License

Open Source License

Parameter

Parameter Description
T The type of the Collection s elements.
collection The Collection to add to.
elementsToAdd The elements to add.

Declaration

public static <T> void addAll(Collection<T> collection, T... elementsToAdd) 

Method Source Code


//package com.java2s;
// Public License. See LICENSE.TXT for details.

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

public class Main {
    /**// w  w  w.j  a v a 2s . com
     * Adds all elements to the {@link Collection}. 
     * @param <T> The type of the {@link Collection}s elements.
     * @param collection The {@link Collection} to add to.
     * @param elementsToAdd The elements to add.
     */
    public static <T> void addAll(Collection<T> collection, T... elementsToAdd) {
        if (collection != null && elementsToAdd != null) {
            Collections.addAll(collection, elementsToAdd);
        }
    }
}

Related

  1. addAll(Collection coll1, Collection coll2)
  2. addAll(Collection collection, Collection toAdd)
  3. addAll(Collection collection, Iterable items)
  4. addAll(Collection collection, T... array)
  5. addAll(Collection collection, T... elementsToAdd)
  6. addAll(Collection collection, T... newElements)
  7. addAll(Collection collection, T[] array)
  8. addAll(Collection collection, T[] array)
  9. addAll(Collection collection, T[] items)