java
BigDecimal.ZERO.equals(money);BigDecimal.ZERO.equals(money);需要额外注意: Bigdecimal的equals方法先比较scale。不仅仅比较值的大小是否相等。
java
BigDecimal x = new BigDecimal("1");
BigDecimal y = new BigDecimal("1.00");
System.out.println(x.equals(y)); // false
System.out.println(x.compareTo(y) == 0 ? "true": "false"); // trueBigDecimal x = new BigDecimal("1");
BigDecimal y = new BigDecimal("1.00");
System.out.println(x.equals(y)); // false
System.out.println(x.compareTo(y) == 0 ? "true": "false"); // trueBigDecimal (Java Platform SE 6)
UnlikecompareTo, this method considers twoBigDecimalobjects equal only if they are equal in value and scale (thus 2.0 is not equal to 2.00 when compared by this method).