Example usage for java.util.stream LongStream reduce

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

Introduction

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

Prototype

long reduce(long identity, LongBinaryOperator op);

Source Link

Document

Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value.

Usage

From source file:Main.java

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

    long v = b.reduce(0, Long::sum);
    System.out.println(v);/* w w w.  j av  a 2 s.com*/

}