Here you can find the source of addAll(Collection
Parameter | Description |
---|---|
c | collection to which add each element of array. |
array | ~ items |
public static <E, T extends E> Collection<E> addAll(Collection<E> c, T... array)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.List; public class Main { /**//w ww . j a va2s. com * Adds objects in array to the given collection * * @param c * collection to which add each element of array. * @param array * ~ items * @return the same collection which is passed as argument */ public static <E, T extends E> Collection<E> addAll(Collection<E> c, T... array) { for (T obj : array) { c.add(obj); } return c; } /** * Adds the given item to the list at specified <code>index</code>. * <p/> * if <code>index</code> is greater than list size, it simply appends to the * list. * * @param list * collection of elements * @param index * specific index * @param item * object to add. */ public static <E, T extends E> void add(List<E> list, int index, T item) { if (index < list.size()) { list.add(index, item); } else { list.add(item); } } }