Example usage for java.util.stream IntStream reduce

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

Introduction

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

Prototype

int reduce(int identity, IntBinaryOperator 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) {
    IntStream i = IntStream.of(6, 5, 7, 1, 2, 3, 3);
    int v = i.reduce(0, (n1, n2) -> n1 + n2);

    System.out.println(v);//from   w w w  .ja  va2 s .  com

}