Java Set Intersect intersection(final Set set1, final Set set2)

Here you can find the source of intersection(final Set set1, final Set set2)

Description

intersection

License

Apache License

Declaration

public static <E> Set<E> intersection(final Set<E> set1, final Set<E> set2) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class Main {

    public static <E> Set<E> intersection(final Set<E> set1, final Set<E> set2) {
        Set<E> set = new HashSet<>(set1);
        set.retainAll(set2);//from   w ww . j a  v a 2 s.  c  o m
        return Collections.unmodifiableSet(set);
    }
}

Related

  1. intersect(Set one, Set two)
  2. intersect(Set set1, Set set2)
  3. intersect(Set a, Set b)
  4. intersect(Set a, Set b)
  5. intersectComparable(Set left, Set right)
  6. intersection(Set a, Set b)
  7. intersection(Set sa, Set sb)
  8. intersection(Set first, Set second)
  9. intersection(Set s1, Set s2)