Back
Say, have two Hashset, how to calculate the intersection of them?
Set<String> s1 = new HashSet<String>();Set<String> s2 = new HashSet<String>();S1 INT S2 ?
Set<String> s1 = new HashSet<String>();
Set<String> s2 = new HashSet<String>();
S1 INT S2 ?
Yes there is retainAll check out this
Set<Type> intersection = new HashSet<Type>(s1);intersection.retainAll(s2);
Set<Type> intersection = new HashSet<Type>(s1);
intersection.retainAll(s2);
31k questions
32.8k answers
501 comments
693 users