Easy java streams

groupingBy versus partitioningBy

The 30 second answer

groupingBy takes a classifier and builds a map with whatever keys appear. partitioningBy takes a boolean predicate and always returns a map with both true and false keys. Both accept downstream collectors. For unordered parallel work there is also groupingByConcurrent.

groupingBy(Function) → Map<K, List<T>> with arbitrary keys, only keys that occur. partitioningBy(Predicate) → Map<Boolean, List<T>>, always with both true and false.

Both accept downstream collectors. groupingByConcurrent exists for unordered parallel use.

Sources:

Sources (0)
See inline citations in the answer above.