I have two sets, A and B, of the same type.
I have to find if A contains any element from the set B.
What would be the best way to do that without iterating
Use retainAll() in the Set interface. This method provides an intersection of elements common in both sets. See the API docs for more information.
retainAll()