BigDecimal equals() versus compareTo()
Consider the simple test class: import java.math.BigDecimal; /** * @author The Elite Gentleman * */ public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub BigDecimal x = new BigDecimal("1"); BigDecimal y = new BigDecimal("1.00"); System.out.println(x.equals(y)); System.out.println(x.compareTo(y) == 0 ? "true": "false"); } } You can (consciously) say that x is equal to y (not object reference), but when you run the program, the following result shows: false true Question: What's the difference between compareTo() and equals() in