"collect" method

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了"collect" method相关的知识,希望对你有一定的参考价值。

1.The collect is declared by the Interface of Stream.The param is Collector Interface.

<R, A> R collect(Collector<? super T, A, R> collector);

 

2.The Collector Interface mainly contains 4 functions about:

  (1)creation of a new result container ({@link #supplier()})

  (2)incorporating a new data element into a result container ({@link #accumulator()})

  (3)combining two result containers into one ({@link #combiner()})

  (4)performing an optional final transform on the container ({@link #finisher()}

3.The Collectors Class has a inner class which implements above Collector.So you can invoke collect by this assistant class (Collectors).The Collectors class implement some common operations.

  ex:

public static <T>
    Collector<T, ?, List<T>> toList() {
        return new CollectorImpl<>((Supplier<List<T>>) ArrayList::new, List::add,
                                   (left, right) -> { left.addAll(right); return left; },
                                   CH_ID);
    }

 

  

  

以上是关于"collect" method的主要内容,如果未能解决你的问题,请参考以下文章

wpf listcollectionview怎么转换成对象

无法将当前 JSON 对象(例如 "name":"value")反序列化为类型 'System.Collections.Generic.List`1

"collect" method

带索引的Ruby数组collect

JSON.Net - 无法将当前 json 对象(例如 "name":"value")反序列化为类型 'system.collections.generic.l

更新到 Office 2016 后的 VBA 脚本错误 (CreateObject("System.Collections.ArrayList"))