Jan 31

Use the compareTo() method instead of the equals() method.
equals() only considers two BigDecimal’s to be equal if they have same value and scale (eg. 1.25 is not equal to 1.250 when using equals() method).

BigDecimal a = new BigDecimal("1.25");
BigDecimal b = new BigDecimal("1.250");
if (a.compareTo(b)==0)
   System.out.println("They are equal");

written by objects \\ tags: , ,