DoubleStream sum()
returns the
sum of elements in this stream.
sum
has the following syntax.
double sum()
The following example shows how to use sum
.
import java.util.stream.DoubleStream; // ww w .j av a 2 s .c om public class Main { public static void main(String[] args) { DoubleStream d = DoubleStream.of(1.2,2.3,4.5); double v = d.sum(); System.out.println(v); } }
The code above generates the following result.