stream() 对Bigdecimal类型数据求和

//List对象集合
List mOrderGoodsList1;

getActualPayTotalAmount属性类型为BigDecimal

stream()求和

BigDecimal invoiceAmount = mOrderGoodsList1.stream().map(MOrderGoods::getActualPayTotalAmount).reduce(BigDecimal.ZERO, BigDecimal::add);

你可能感兴趣的:(jdk8新特性,java)