java - Intersection of two sets -


is easy way intersection of 2 sets? have:

    set<long> set1 = {1,2,3}     set<long> set2 = {2,3,4} 

and looking or method like:

    set<long> intersection = new hashset<>();     intersection.intersect(set1, set2); 

and intersection.tostring() produce me set contains {2,3}

you can use retainall().

note modify 1 of collections might want create copy first.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -