If you look at the reduce signature, the type of identifier should be the type of stream elements. In this case, it will be double[] . This will also give acc type double[] .
There is overload where you can put a different type of battery, but you also need to pass a combiner to combine 2 batteries.
You can do it:
double result = Arrays.stream(myArray) .reduce(0D, (acc, i) -> acc + Arrays.stream(i).sum(), Double::sum);
Where 0D is the literal double , and Double::sum used to combine 2 batteries.
Alternatively, this may be more convenient to do:
double result = Arrays.stream(myArray) .flatMapToDouble(DoubleStream::of) .sum();
source share