Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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:
 *    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;
        }
    }
}