Java Collection Add addAll(Collection collection, Collection toAdd)

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

Description

add All

License

Open Source License

Declaration

public static <T> boolean addAll(Collection<T> collection, Collection<? extends T> toAdd) 

Method Source Code

//package com.java2s;

import java.util.Collection;

public class Main {
    public static <T> boolean addAll(Collection<T> collection, Collection<? extends T> toAdd) {
        int size = toAdd.size();
        boolean result = false;
        if (size > 0) {
            if (size < 10)
                for (T element : toAdd)
                    result |= collection.add(element);
            else//from  w  w w  . j a v a  2 s .c o  m
                result = collection.addAll(toAdd);
        }
        return result;
    }

    @SafeVarargs
    public static <T> boolean addAll(Collection<T> collection, T... toAdd) {
        int size = toAdd.length;
        boolean result = false;
        if (size > 0) {
            for (T element : toAdd)
                result |= collection.add(element);
        }
        return result;
    }
}

Related

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