Here you can find the source of addAll(Collection
public static <T> boolean addAll(Collection<T> collection, Collection<? extends T> toAdd)
//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; } }