1、List求 BigDecimal的和
List<BigDecimal> scoreList = new ArrayList<>();
scoreList.add(new BigDecimal("12"));
scoreList.add(new BigDecimal("15"));
scoreList.add(new BigDecimal("16"));
// 总分
BigDecimal totalcore = scoreList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
2、List求 BigDecimal的和
BigDecimal result2 = userList.stream()
// 将user对象的mongey取出来map为Bigdecimal
.map(User::getMoney)
// 使用reduce聚合函数,实现累加器
.reduce(BigDecimal.ZERO, BigDecimal::add);