Example usage for java.util.stream LongStream collect

List of usage examples for java.util.stream LongStream collect

Introduction

In this page you can find the example usage for java.util.stream LongStream collect.

Prototype

<R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner);

Source Link

Document

Performs a mutable reduction operation on the elements of this stream.

Usage

From source file:Main.java

public static void main(String[] args) {
    LongStream b = LongStream.of(1L, 2L, 3L, 4L);

    List<Long> v = b.collect(ArrayList::new, ArrayList::add, ArrayList::addAll);

    System.out.println(v);/*from   w  ww . jav a 2 s.  c o m*/
}