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;

public class Main {
    /**
     * an alternative which returns slightly more granular info than boolean pass/fail.
     * @return the number of add operations which "succeed" (modify the collection)
     * @see Collection#addAll(Collection)
     */
    public static <E> int addAll(Collection<E> collection, Iterator<? extends E> add) {
        int retVal = 0;
        while (add.hasNext())
            if (collection.add(add.next()))
                ++retVal;
        return retVal;
    }
}