Java Set Difference difference(final Set set1, final Set set2)

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

Description

difference

License

Apache License

Declaration

public static <E> Set<E> difference(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> difference(final Set<E> set1, final Set<E> set2) {
        Set<E> set = new HashSet<>(set1);
        set.removeAll(set2);/*from  ww w  .j  a v a  2  s  . c o m*/
        return Collections.unmodifiableSet(set);
    }
}

Related

  1. computeDifference(Set a, Set b, String prefix, boolean exactMatch)
  2. diffAbyB(Set setA, Set setB)
  3. difference(final Set first, final Set second)
  4. difference(Set a, Set b)
  5. difference(Set first, Set second)
  6. difference(Set s1, Set s2)