BigDecimal equals() Method in Java Last Updated : 04 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The java.math.BigDecimal.equals() method checks for equality of a BigDecimal value with the object passed. This method considers two BigDecimal objects equal if only if they are equal in value and scale. Syntax: public boolean equals(Object obj) Parameters: This function accepts an Object obj as a mandatory parameter for comparison with this BigDecimal object. Return Value: This method returns boolean true if and only if the Object passed as parameter is a BigDecimal whose value and scale are equal to that of this BigDecimal object and returns false otherwise. Thus, this function does not return true when it compares 124.0 and 124.0000. Examples: Input: b1 = new BigDecimal("4743.00") b2 = new BigDecimal("4743.00000") Output: false Input: b1 = new BigDecimal(4743) b2 = new BigDecimal("4743") Output: true Below programs illustrate equals() method of BigDecimal class: Program 1: Java // Java program to demonstrate equals() method import java.io.*; import java.math.*; public class GFG { public static void main(String[] args) { // Creating 2 BigDecimal objects BigDecimal b1, b2; b1 = new BigDecimal("4743.00"); b2 = new BigDecimal("4743.00000"); if (b1.equals(b2)) { System.out.println(b1 + " and " + b2 + " are equal."); } else { System.out.println(b1 + " and " + b2 + " are not equal."); } } } Output: 4743.00 and 4743.00000 are not equal. Program 2: Java // Java program to demonstrate equals() method import java.io.*; import java.math.*; public class GFG { public static void main(String[] args) { // Creating 2 BigDecimal objects BigDecimal b1, b2; b1 = new BigDecimal(67891); b2 = new BigDecimal("67891"); if (b1.equals(b2)) { System.out.println(b1 + " and " + b2 + " are equal."); } else { System.out.println(b1 + " and " + b2 + " are not equal."); } } } Output: 67891 and 67891 are equal. Comment More infoAdvertise with us Next Article BigDecimal min() Method in Java R RICHIK BHATTACHARJEE Follow Improve Article Tags : Misc Java Java-Functions java-math Java-BigDecimal Java-math-package +2 More Practice Tags : JavaMisc Similar Reads DecimalFormat equals() method in Java The equals() method is a built-in method of the java.text.DecimalFormat class accepts an argument which is an object and returns true if this argument object is same as the object, else it returns false. Syntax: public boolean equals(Object arg) Parameters: The function accepts a single mandatory pa 2 min read DecimalFormat equals() method in Java The equals() method is a built-in method of the java.text.DecimalFormat class accepts an argument which is an object and returns true if this argument object is same as the object, else it returns false. Syntax: public boolean equals(Object arg) Parameters: The function accepts a single mandatory pa 2 min read BigDecimal hashCode() Method in Java The java.math.BigDecimal.hashCode() returns the hash code for this BigDecimal. The hashcode will generally not be the same for two BigDecimal objects with equal values and different scale (like 4743.0 and 4743.00). Syntax: public int hashCode() Parameters: This method does not accept any parameters. 2 min read BigDecimal hashCode() Method in Java The java.math.BigDecimal.hashCode() returns the hash code for this BigDecimal. The hashcode will generally not be the same for two BigDecimal objects with equal values and different scale (like 4743.0 and 4743.00). Syntax: public int hashCode() Parameters: This method does not accept any parameters. 2 min read BigDecimal min() Method in Java The java.math.BigDecimal.min(BigDecimal val) method in Java is used to compare two BigDecimal values and return the minimum of the two. Syntax: public BigDecimal min(BigDecimal val) Parameters: The function accepts a BigDecimal object val as parameter whose value is compared with that of this BigDec 2 min read BigDecimal min() Method in Java The java.math.BigDecimal.min(BigDecimal val) method in Java is used to compare two BigDecimal values and return the minimum of the two. Syntax: public BigDecimal min(BigDecimal val) Parameters: The function accepts a BigDecimal object val as parameter whose value is compared with that of this BigDec 2 min read Like