For example, if I intend to partition some elements, I could do something like:
Stream.of(\"I\", \"Love\", \"Stack Overflow\")
.collect(Collectors.part
Another difference between groupingBy and partitioningBy is that the former takes a Function super T, ? extends K> and the latter a Predicate super T>.
When you pass a method reference or a lambda expression, such as s -> s.length() > 3, they can be used by either of these two methods (the compiler will infer the functional interface type based on the type required by the method you choose).
However, if you have a Predicate instance, you can only pass it to Collectors.partitioningBy(). It won't be accepted by Collectors.groupingBy().
And similarly, if you have a Function instance, you can only pass it to Collectors.groupingBy(). It won't be accepted by Collectors.partitioningBy().