Im trying to use Java 8 streams to combine lists. How can I get a \"symmetric difference list\" (all object that only exist in one list) from two existing lists. I know how
An alternative approach, albeit not as elegant as one line streams:
HashMap y = new HashMap<>();
bigCarSet ().forEach(i -> y.put(i, !y.containsKey(i)));
bigCarList().forEach(i -> y.put(i, !y.containsKey(i)));
y.entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey)
.collect(Collectors.toList());
which can be simplified to at least:
HashMap y = new HashMap<>();
Stream.concat(list1.stream(), list2.stream()).forEach(i -> y.put(i, !y.containsKey(i)));
y.entrySet().stream().filter(Map.Entry::getValue)
.map(Map.Entry::getKey).collect(Collectors.toList());