Fill in the blank so this code prints 8.0.
IntStream stream = IntStream.of(6, 10); LongStream longs = stream.mapToLong(i -> i); System.out.println(___);
average()
.get()
average()
.getAsDouble()
getAverage()
.get()
getAverage()
.getAsDouble()
B.
Primitive streams, like LongStream, declare an average()
method, while summary statistics classes, like LongSummaryStatistics, declare a getAverage()
method, making Options C and D incorrect.
The average()
method returns an OptionalDouble object, which declares a getAsDouble()
method rather than a get()
method.
Therefore, Option A is incorrect, and Option B is correct.