Java Collection Add addAll(Collection ret, Object[] elements)

Here you can find the source of addAll(Collection ret, Object[] elements)

Description

add All

License

Open Source License

Parameter

Parameter Description
ret a parameter
elements a parameter

Declaration

@SuppressWarnings({ "rawtypes", "unchecked" })
public static void addAll(Collection ret, Object[] elements) 

Method Source Code

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

import java.util.Collection;

import java.util.Iterator;

public class Main {
    /**/*w w  w.ja  v a 2  s.  co m*/
     * @param ret
     * @param elements
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static void addAll(Collection ret, Object[] elements) {
        if (elements != null)
            for (int i = 0; i < elements.length; i++)
                ret.add(elements[i]);
    }

    public static void addAll(Collection<String> ret, String[] elements) {
        if (elements != null)
            for (int i = 0; i < elements.length; i++)
                ret.add(elements[i]);
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static void addAll(Collection ret, Iterator elements) {
        if (elements != null)
            while (elements.hasNext())
                ret.add(elements.next());
    }
}

Related

  1. addAll(C collection, Iterable add)
  2. addAll(C collection, T... elements)
  3. addAll(Collection collection, Iterator iterator)
  4. addAll(Collection collection, Object[] array)
  5. addAll(Collection collection, Object[] array)
  6. addAll(Collection source, Collection target)
  7. addAll(Collection col, Iterable iterable)
  8. addAll(Collection collection, Iterable toAdd)
  9. addAll(Collection addTo, Iterable elementsToAdd)