Symmetric difference of two sets in Java

前端 未结 7 2001
礼貌的吻别
礼貌的吻别 2021-02-03 21:49

There are two TreeSets in my app:

set1 = {501,502,503,504}
set2 = {502,503,504,505}

I want to get the symmetric difference of thes

相关标签:
7条回答
  • 2021-02-03 22:51

    You could use CollectionUtils#disjunction

    EDIT:

    Alternatively with less pre-Java-5-ness, use Guava Sets#symmetricDifference

    0 讨论(0)
提交回复
热议问题