bigdecimal为null时设置为0

当bigdecimal类型数据为null时,如果不处理会报空指针。需要这样设置一下:
例如:

private BigDecimal money;

publist BigDecimal getMoney(){
return money ==null ? BigDecimal.ZERO:money;
}

这样在money字段值为null时避免报空指针异常

你可能感兴趣的:(java)