### Question:
SetUtils { public static <E> SetView<E> difference(final Set<? extends E> a, final Set<? extends E> b) { if (a == null || b == null) { throw new NullPointerException("Sets must not be null."); } final Predicate<E> notContainedInB = new Predicate<E>() { @Override public boolean evaluate(E object) { return !b.contains(object); } }; return new SetView<E>() { @Override public boolean contains(Object o) { return a.contains(o) && !b.contains(o); } @Override public Iterator<E> createIterator() { return IteratorUtils.filteredIterator(a.iterator(), notContainedInB); } }; } private  SetUtils(); static Set<E> emptySet(); @SuppressWarnings("unchecked") // empty set is OK for any type static SortedSet<E> emptySortedSet(); static Set<T> emptyIfNull(final Set<T> set); static boolean isEqualSet(final Collection<?> set1, final Collection<?> set2); static int hashCodeForSet(final Collection<T> set); static Set<E> newIdentityHashSet(); static Set<E> synchronizedSet(final Set<E> set); static Set<E> unmodifiableSet(final Set<? extends E> set); static Set<E> predicatedSet(final Set<E> set, final Predicate<? super E> predicate); static Set<E> transformedSet(final Set<E> set,
                                            final Transformer<? super E, ? extends E> transformer); static Set<E> orderedSet(final Set<E> set); static SortedSet<E> synchronizedSortedSet(final SortedSet<E> set); static SortedSet<E> unmodifiableSortedSet(final SortedSet<E> set); static SortedSet<E> predicatedSortedSet(final SortedSet<E> set,
                                                       final Predicate<? super E> predicate); static SortedSet<E> transformedSortedSet(final SortedSet<E> set,
                                                        final Transformer<? super E, ? extends E> transformer); static SortedSet<E> unmodifiableNavigableSet(final NavigableSet<E> set); static SortedSet<E> predicatedNavigableSet(final NavigableSet<E> set,
                                                          final Predicate<? super E> predicate); static SortedSet<E> transformedNavigableSet(final NavigableSet<E> set,
                                                           final Transformer<? super E, ? extends E> transformer); static SetView<E> union(final Set<? extends E> a, final Set<? extends E> b); static SetView<E> difference(final Set<? extends E> a, final Set<? extends E> b); static SetView<E> intersection(final Set<? extends E> a, final Set<? extends E> b); static SetView<E> disjunction(final Set<? extends E> a, final Set<? extends E> b); @SuppressWarnings("rawtypes")
    static final SortedSet EMPTY_SORTED_SET; }### Answer:
@Test public void difference() { final SetView<Integer> set = SetUtils.difference(setA, setB); assertEquals(2, set.size()); assertTrue(set.contains(1)); assertTrue(set.contains(2)); for (Integer i : setB) { assertFalse(set.contains(i)); } final Set<Integer> set2 = SetUtils.difference(setA, SetUtils.<Integer>emptySet()); assertEquals(setA, set2); try { SetUtils.difference(setA, null); fail("Expecting NullPointerException"); } catch (NullPointerException npe) { } try { SetUtils.difference(null, setA); fail("Expecting NullPointerException"); } catch (NullPointerException npe) { } }