There are two TreeSet
s in my app:
set1 = {501,502,503,504}
set2 = {502,503,504,505}
I want to get the symmetric difference of thes
You could try Sets.symmetricDifference()
from Eclipse Collections.
Set set1 = new TreeSet<>(Arrays.asList(501,502,503,504));
Set set2 = new TreeSet<>(Arrays.asList(502,503,504,505));
Set symmetricDifference =
Sets.symmetricDifference(set1, set2);
Assert.assertEquals(
new TreeSet<>(Arrays.asList(501, 505)),
symmetricDifference);
Note: I am a committer for Eclipse Collections.