Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.*;

public class Main {
    public static <E> Set<E> intersect(Set<E> a, Set<E> b) {
        Set<E> intersect = new HashSet<>();
        for (E entryA : a) {
            if (b.contains(entryA)) {
                intersect.add(entryA);
            }
        }
        for (E entryB : b) {
            if (a.contains(entryB)) {
                intersect.add(entryB);
            }
        }
        return intersect;
    }
}