I would like to get the max value out of a list using java 8 stream methods.
The structure is the following:
using reduce
int max1 = arrRound.stream()
.flatMap(r -> r.getHits().stream())
.mapToInt(h -> h.getPrizeAmount())
.reduce(Math::max) //returns OptionalInt
.orElse(Integer.MIN_VALUE);
or
int max2 = arrRound.stream()
.flatMap(r -> r.getHits().stream())
.mapToInt(h -> h.getPrizeAmount())
.reduce(Integer.MIN_VALUE, Math::max);