Why summaryStatistics() method on an empty IntStream returns max and min value of integer as the maximum and minimum int value present in the stream?
IntStream
To find a minimum int
value in any array you typically initialize the default to Integer.MAX_VALUE
.
int min = Integer.MAX_VALUE;
for (int i : somearray) {
if (i < min) {
min = i;
}
}
return min;
So if there was nothing to iterate, the value of the default min
would be returned. For
max, the default max
is initialized to Integer.MIN_VALUE
.