Let's say I have two sets:
Set<String> set1 = new HashSet<>(Arrays.asList("a", "b", "c", "d", "e") );
Set<String> set2 = new HashSet<>(Arrays.asList("b", "c", "d", "e", "f") );
What is the easiest and best way, performance wise, to compare the two and get a List
of the differences?
Meaning I should get a list that contains "a"
and "f"
. The tricky thing here is that the differences can occur in either of the list.
I could only make it work with for loops, but there has to be an easier way...