Here you can find the source of addAll(final Collection
Parameter | Description |
---|---|
IllegalArgumentException | if <code>collection == null</code> |
public static <T> int addAll(final Collection<T> collection, final T... elements) throws IllegalArgumentException
//package com.java2s; /******************************************************************************* * Portions created by Sebastian Thomschke are copyright (c) 2005-2016 Sebastian * Thomschke./*from w ww . ja va 2 s .c om*/ * * All Rights Reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Sebastian Thomschke - initial implementation. *******************************************************************************/ import java.util.Collection; public class Main { /** * @throws IllegalArgumentException if <code>collection == null</code> */ public static <T> int addAll(final Collection<T> collection, final T... elements) throws IllegalArgumentException { if (elements == null) return 0; int count = 0; for (final T elem : elements) if (collection.add(elem)) count++; return count; } }