官术网_书友最值得收藏!

Partitioning

Partitioning is a special condition of grouping where the elements of the streams are partitioned based on the logic of the predicate function being passed to the Collectors. The predicate function based on a Boolean logic evaluates each element of the stream to either be true or false. The resultant output of the partitioningBy() method is a Map having two keys, true and false, and a list of values of streams associated with each Boolean value depending on the output of the predicate function:

//Partition Collectors
Map<Boolean,List<String>>partitionExample=streamSupplier.get().collect(Collectors.partitioningBy( x->x.toString().length() > 5 ));
System.out.println("Patitioning of elements on the basis of its length :: "+partitionExample);
主站蜘蛛池模板: 集安市| 九江市| 绍兴市| 浦北县| 兰州市| 札达县| 定陶县| 晋中市| 莎车县| 桐乡市| 东阿县| 巴楚县| 崇仁县| 象州县| 堆龙德庆县| 旺苍县| 博爱县| 久治县| 冷水江市| 什邡市| 木里| 安顺市| 西丰县| 嘉峪关市| 白河县| 霍林郭勒市| 安泽县| 民乐县| 富平县| 文水县| 镇原县| 海南省| 郑州市| 左贡县| 宜良县| 日喀则市| 拉萨市| 会理县| 中西区| 信阳市| 兰州市|