List strem sum

最近一直用到,特此记录一下

int ageSum = distributionOrders.stream().collect(Collectors.summingInt(User::getAge));



BigDecimal paymentPrice = distributionOrders.stream().map(User::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);

你可能感兴趣的:(java)