Java Collection Add addArray(Collection col, T[] array)

Here you can find the source of addArray(Collection col, T[] array)

Description

Adds the whole array to the collection.

License

Open Source License

Parameter

Parameter Description
col collection to add to
array array to add to collection

Return

collection

Declaration

public static <T> Collection<T> addArray(Collection<T> col, T[] array) 

Method Source Code

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

import java.util.Collection;

public class Main {
    /**/*from   w  ww.j  ava 2s.  c om*/
     * Adds the whole array to the collection.
     *
     * @param col collection to add to
     * @param array array to add to collection
     * @return collection
     */
    public static <T> Collection<T> addArray(Collection<T> col, T[] array) {
        if (array == null) {
            return col;
        }

        for (T a : array) {
            col.add(a);
        }

        return col;
    }
}

Related

  1. addAllNotNull(final Collection c, final E... elements)
  2. addAllOrSame(Collection collection, Collection newElements)
  3. addAllSafe(Collection collection1, Collection collection2)
  4. addAllUncontained(Collection col1, Collection col2)
  5. addAllUnique(final Collection collection, final Collection values)
  6. addArray(java.util.Collection v, T array[])
  7. addArrayToCollection(T[] array, Collection collection)
  8. addArrayToCollection(T[] array, Collection collection)
  9. addCheck(Collection c, Object o)