Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Collection;
import java.util.Iterator;
import com.google.common.base.Preconditions;

public class Main {
    /**
     * @throws IllegalArgumentException if an add operation "soft fails" (does not modify the collection)
     * @see Collection#addAll(Collection)
     */
    public static <E> void addAllForce(Collection<E> collection, Iterator<? extends E> add) {
        while (add.hasNext()) {
            E next = add.next();
            Preconditions.checkArgument(collection.add(next), "collection did not accept next element %s: %s", next,
                    collection);
        }
    }
}