The answer is in :
Unlike , this method considers two
BigDecimal
objects equal only if they are equal in value and scale (thus 2.0 is not equal to 2.00 when compared by this method).
In other words: equals()
checks if the BigDecimal
objects are exactly the same in every aspect. compareTo()
"only" compares their numeric value.
注意:java BigDecimal 比较值大小要用compartTo(x)方法。