首页 > 代码库 > "collect" method
"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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。