Is there any built-in functionality for classical set operations on the java.util.Collection class? My specific implementation would be for ArrayList, but this sounds like s
For mutable operations see accepted answer.
For an imutable variant you can do this with java 8
subtraction
set1 .stream() .filter(item-> !set2.contains(item)) .collect(Collectors.toSet())
intersection
set1 .stream() .filter(item-> set2.contains(item)) .collect(Collectors.toSet())