Java BigDecimal.equals(Object x)
Syntax
BigDecimal.equals(Object x) has the following syntax.
public boolean equals(Object x)
Example
In the following code shows how to use BigDecimal.equals(Object x) method.
//from w ww . j a v a 2 s .c o m
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) {
BigDecimal bg1 = new BigDecimal("25.00");
BigDecimal bg2 = new BigDecimal("25.00");
BigDecimal bg3 = new BigDecimal("25");
// assign the result of equals method to b1, b2
Boolean b1 = bg1.equals(bg2);
Boolean b2 = bg1.equals(bg3);
System.out.println(b1);
System.out.println(b2);
}
}
The code above generates the following result.