There are two TreeSets in my app:
TreeSet
set1 = {501,502,503,504} set2 = {502,503,504,505}
I want to get the symmetric difference of thes
use retain all,remove all then addAll to do a union of existing set.
intersectionSet.retainAll(set2) // intersectionSet is a copy of set1 set1.addAll(set2); // do a union of set1 and set2 then remove the duplicates set1.removeAll(intersectionSet);