Skip to content

Comment on Reduce operation in Java 8

Comments

Stream already has a max method:

    return listOfTxnAmounts.stream().max(BigDecimal::compareTo).orElse(BigDecimal.ZERO);
(They behave differently for a list that only has negative numbers, but it seems like that isn't a part of the domain anyway)
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.