I have a two HashSet objects with elements {A,B,C,D}
and {A,B,X,Y}
. I need a third set with unique elements from both sets result will be like {C,D,X,Y}
.
Asked
Active
Viewed 411 times
0
-
Your code ? what have you tried so far ? – voucher_wolves Nov 07 '16 at 14:20
-
2look at `Set#retainAll()` – Andrew Tobilko Nov 07 '16 at 14:20
-
4Isn't B unique? – nakano531 Nov 07 '16 at 14:22
-
1Sounds like you're asking for an implementation of [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference). See also [What is the best way get the symmetric difference between two sets in java?](/q/8064570) and [Symmetric difference of two sets in Java?](/q/8064570). If you meant something else, you should probably [edit] your question to clarify what's different in your situation. – Toby Speight Nov 07 '16 at 14:32