Intersection is done with Collection.retainAll
; subtraction with Collection.removeAll
; union with Collection.addAll
. In each case, as Set
will act like a set and a List
will act like a list.
As mutable objects, they operate in place. You’ll need to explicitly copy if you want to retain the original mutable object unmutated.