Here you can find the source of addAll(Collection
Parameter | Description |
---|---|
collection | the collection to which things are to be added. |
newElements | the new elements to add to the collection. |
public static <T> Collection<T> addAll(Collection<T> collection, T... newElements)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**/* ww w . j a va2s. co m*/ * Add the contents of an array to a collection and return the collection. * <p/>Returning the collection facilitates certain constructs including: * <blockquote> * <tt>doit( ObtuseUtil.addAll( new LinkedList<String>(), new String[] { "hello", "there", "world" } );</tt> * </blockquote> * * @param collection the collection to which things are to be added. * @param newElements the new elements to add to the collection. * @return the collection after the elements have been added. */ public static <T> Collection<T> addAll(Collection<T> collection, T... newElements) { Collections.addAll(collection, newElements); return collection; } }