Java Collection Add addAll(Collection col, T[] arr)

Here you can find the source of addAll(Collection col, T[] arr)

Description

add All

License

Open Source License

Declaration

public static <T> void addAll(Collection<T> col, T[] arr) 

Method Source Code


//package com.java2s;

import java.util.Collection;

import java.util.Map;

public class Main {
    public static <T> void addAll(Collection<T> col, T[] arr) {
        if (isEmpty(arr)) {
            return;
        }//from   ww  w .ja va 2 s . co  m
        for (T val : arr) {
            col.add(val);
        }
    }

    public static <T> boolean isEmpty(T[] vals) {
        return vals == null || vals.length == 0;
    }

    public static <T> boolean isEmpty(T[] vals, boolean checkNullVal) {
        boolean isEmpty = vals == null || vals.length == 0;
        if (isEmpty) {
            return true;
        }
        if (checkNullVal) {
            for (T val : vals) {
                if (val != null) {
                    return false;
                }
            }
            isEmpty = true;
        }
        return isEmpty;
    }

    public static boolean isEmpty(Collection<?> col) {
        return col == null || col.isEmpty();
    }

    public static <T, V> boolean isEmpty(Map<T, V> map) {
        return map == null || map.isEmpty();
    }
}

Related

  1. addAll(Collection collection, Iterable iterable)
  2. addAll(Collection collection, Iterator iterator)
  3. addAll(Collection pCollection, Iterator pIterator)
  4. addAll(Collection integerCollection, int[] intArray)
  5. addAll(Collection c, T[] a)
  6. addAll(Collection coll, T... elems)
  7. addAll(Collection coll1, Collection coll2)
  8. addAll(Collection collection, Collection toAdd)
  9. addAll(Collection collection, Iterable items)