Getting the difference between two sets
So if I have two sets: Set<Integer> test1 = new HashSet<Integer>(); test1.add(1); test1.add(2); test1.add(3); Set<Integer> test2 = new HashSet<Integer>(); test2.add(1); test2.add(2); test2.add(3); test2.add(4); test2.add(5); Is there a way to compare them and only have a set of 4 and 5 returned? 10 Answers 10