Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Main {
    /**
     * Build a set from any {@link Iterator}.
     * @param it
     * @return
     */
    public static <E> Set<E> buildSetFromIterator(final Iterator<E> it) {
        final Set<E> set = new HashSet<>();

        while (it.hasNext()) {
            set.add(it.next());
        }

        return set;
    }
}