Java / Set and its implementations
How do you calculate the intersection of two HashSet in Java?
Use retainAll method that retains only the elements in the set that are contained in the specified collection (optional operation).
In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.
More Related questions...