- Apache Spark 2.x for Java Developers
- Sourav Gulati Sumit Kumar
- 45字
- 2021-07-02 19:01:59
Groupings
The elements of streams can also be grouped using Collectors, returning a map, such that for a key of type T, the Collector generates a Map<T,List<Y>>:
//Grouping Collectors
Map<Integer,List<String>>groupExample= streamSupplier.get().collect(Collectors.groupingBy(x-> x.toString().length()));
System.out.println("Grouping stream elements on the basis of its length :: " + groupExample);
推薦閱讀