Help the world stop coronavirus! Stay home!

Prev Next

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.

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

Show more question and Answers...

Queue and its implementations

Comments & Discussions