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.HashSet;
import java.util.Set;

public class Main {
    /**
     * Returns intersection of two collections.
     *
     * @param <T> the generic type
     * @param coll1 the coll1
     * @param coll2 the coll2
     * @return the collection
     */
    public static <T> Collection<T> intersect(Collection<T> coll1, Collection<T> coll2) {
        Set<T> intersection = new HashSet<T>(coll1);
        intersection.retainAll(new HashSet<T>(coll2));

        return intersection;
    }
}