BigDecimal累加求和数值为0问题:
双层循环中需要对bigdecimal类型数值进行累加要注意:累加之后要赋给新值(totalAmount)
for(int i = 0; i < countStatementList.size(); i++){
BigDecimal amount = new BigDecimal(countStatementList.get(i).getAmount());
BigDecimal totalAmount = new BigDecimal(0);
totalAmount = totalAmount.add(amount);
for(int j = i + 1; j < countStatementList.size(); j++){
totalAmount = totalAmount.add(new BigDecimal(countStatementList.get(j).getAmount()));
}
}