0 votes
1 view
in Java by (3.5k points)

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 ?

1 Answer

0 votes
by (46.1k points)

Yes there is retainAll check out this

Set<Type> intersection = new HashSet<Type>(s1);

intersection.retainAll(s2);

Related questions

0 votes
1 answer
asked Nov 12 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
0 votes
0 answers
asked Nov 20 in Java by Anvi (10.2k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...