IntStream sum() example
Description
IntStream sum()
returns the sum
of elements in this stream.
Syntax
sum
has the following syntax.
int sum()
Example
The following example shows how to use sum
.
import java.util.stream.IntStream;
/*from w w w. j a v a 2s . c o m*/
public class Main {
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);
}
}
The code above generates the following result.