Get difference between two lists
Get difference between two lists
Get difference between two lists
Note: This answer was written before the implementation of the dict type changed, in Python 3.6. Most of the implementation details in this answer still apply, but the listing order of keys in dictionaries is no longer determined by hash values. The set implementation remains unchanged. The order is not arbitrary, but depends on the … Read more
Find the intersection Find the union Subtract the intersection from the union Code: public static void main(String[] args) { Set<Integer> set1 = new HashSet<Integer>(Arrays.asList(1, 2, 3, 4, 5)); Set<Integer> set2 = new HashSet<Integer>(Arrays.asList(1, 3, 6, 7)); Set<Integer> intersection = new HashSet<Integer>(set1); intersection.retainAll(set2); // set1 is now the union of set1 and set2 set1.addAll(set2); // set1 … Read more