list集合中String类型字段转换为BigDecimal类型求和
List<User> userList = new ArrayList<>(); User user1 = new User(); user1.setMoney("10.1");//double类型 userList.add(user1); User user2 = new User (); user2.setMoney("20.1");//double类型 userList.add(user2); BigDecimal sumMoney = userList.stream().map(User::getMoney).map(BigDecimal :: new).reduce(BigDecimal.ZERO,BigDecimal::add);