set Intersection between HashSet - Java Collection Framework

Java examples for Collection Framework:HashSet

Description

set Intersection between HashSet

Demo Code


//package com.java2s;

import java.util.HashSet;

public class Main {
    public static <T> boolean setIntersection(HashSet<T> set1,
            HashSet<T> set2) {
        for (T elem : set1)
            if (set2.contains(elem))
                return true;
        return false;
    }//from   w w  w . jav a  2s.  c o m
}

Related Tutorials