Here you can find the source of removeAll(Collection
Parameter | Description |
---|---|
T | The type of the Collection s elements. |
collection | The Collection to remove from. |
elementsToRemove | The elements to remove. |
public static <T> boolean removeAll(Collection<T> collection, T... elementsToRemove)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Karlsruhe Institute of Technology, Germany * Technical University Darmstadt, Germany * Chalmers University of Technology, Sweden * 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:/*from ww w . j a v a 2 s . c o m*/ * Technical University Darmstadt - initial API and implementation and/or initial documentation *******************************************************************************/ import java.util.Collection; public class Main { /** * Removes all elements from the {@link Collection}. * @param <T> The type of the {@link Collection}s elements. * @param collection The {@link Collection} to remove from. * @param elementsToRemove The elements to remove. * @return {@code true} if the {@link Collection} changed as result of this call. */ public static <T> boolean removeAll(Collection<T> collection, T... elementsToRemove) { if (collection != null && elementsToRemove != null) { boolean result = false; for (T toAdd : elementsToRemove) { result = collection.remove(toAdd) || result; } return result; } else { return false; } } }