It can't be 0.0 since there is no elements in the stream to get an average, hence the Optional is empty.Finally, the average() method computes the average of all the elements, which is 0.0.
The second fragment correct this:
But still, I think the first fragment should be corrected to not cause misunderstandings....the average() method returns an OptionalDouble containing OptionalDouble.empty