diff --git a/src/main/java/org/apache/commons/collections4/SetUtils.java b/src/main/java/org/apache/commons/collections4/SetUtils.java index cf5e438b4c..befd03ccd4 100644 --- a/src/main/java/org/apache/commons/collections4/SetUtils.java +++ b/src/main/java/org/apache/commons/collections4/SetUtils.java @@ -276,8 +276,6 @@ public static SetView intersection(final Set setA, final Set Objects.requireNonNull(setA, "setA"); Objects.requireNonNull(setB, "setB"); - final Predicate containedInB = setB::contains; - return new SetView() { @Override public boolean contains(final Object o) { @@ -286,7 +284,7 @@ public boolean contains(final Object o) { @Override public Iterator createIterator() { - return IteratorUtils.filteredIterator(setA.iterator(), containedInB); + return IteratorUtils.filteredIterator(setA.iterator(), setB::contains); } }; }