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

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

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

javascript - Restarting Supervisor and effect on FlaskSocketIO -