Java Collection Add addAll(Collection collection, T[] array)

Here you can find the source of addAll(Collection collection, T[] array)

Description

Adds all elements from array to collection.

License

Apache License

Parameter

Parameter Description
T the element type
collection the receiving collection, to be modified as a side effect
array the array to take the values from

Return

collection

Declaration

public static <T> Collection<T> addAll(Collection<T> collection, T[] array) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

public class Main {
    /**/*from   www .  j  a v  a  2  s  .com*/
     * Adds all elements from <code>array</code> to <code>collection</code>.
     * 
     * @param <T> the element type
     * @param collection the receiving collection, to be modified as a side effect
     * @param array the array to take the values from
     * @return <code>collection</code>
     */
    public static <T> Collection<T> addAll(Collection<T> collection, T[] array) {
        for (int i = 0; i < array.length; i++) {
            collection.add(array[i]);
        }
        return collection;
    }
}

Related

  1. addAll(Collection collection, T... array)
  2. addAll(Collection collection, T... elementsToAdd)
  3. addAll(Collection collection, T... elementsToAdd)
  4. addAll(Collection collection, T... newElements)
  5. addAll(Collection collection, T[] array)
  6. addAll(Collection collection, T[] items)
  7. addAll(Collection dest, Collection src, Class type)
  8. addAll(Collection dest, Collection orig)
  9. addAll(Collection dest, T... elements)