Example usage for java.util.stream IntStream sum

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

Introduction

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

Prototype

int sum();

Source Link

Document

Returns the sum of elements in this stream.

Usage

From source file:Main.java

public static void main(String[] args) {
    IntStream i = IntStream.of(6, 5, 7, 1, 2, 3, 3);
    int d = i.sum();
    System.out.println(d);/*from   w  w  w . j  a  v  a2  s.c  o  m*/
}

From source file:Main.java

public static void main(String[] args) {

    int[] numbers = { 2, 3, 5, 7, 11, 13 };
    IntStream intStream = Arrays.stream(numbers);
    intStream = intStream.limit(3);// w ww. ja  va  2s. co m
    System.out.println(intStream.sum());
}