java – Is it possible to get both min() and max() from one Stream at once?


Let there be an IntStream , is it possible to get an array or a sheet from it, in which there will be 2 values min and max of the stream? Or is it possible to somehow call the terminal method on the stream more than 1 time?


IntSummaryStatistics stats = IntStream.range(1, 100)

int min = stats.getMin();
int max = stats.getMax();
Scroll to Top