How does combiner in Stream.collect method work in java 8?

前端 未结 3 1830
轮回少年
轮回少年 2020-12-03 04:42

I created simple demo :

public static void main(String[] args) {
        List list2 = Arrays.asList(\"adf\", \"bcd\", \"abc\", \"hgr\", \"jyt\"         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 05:23

    I think that the combiner is only used in parallel Streams (to combine the partial outputs of the parallel computations), so make your Stream parallel.

    String collect = list2.parallelStream().collect(...
    

提交回复
热议问题