Java BigInteger.equals(Object x)

Syntax

BigInteger.equals(Object x) has the following syntax.

public boolean equals(Object x)

Example

In the following code shows how to use BigInteger.equals(Object x) method.


/*  w  w w. j av  a 2 s.c om*/
import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

    BigInteger bi1 = new BigInteger("123");
    BigInteger bi2 = new BigInteger("123");

    // compare bi1 with bi2
    Boolean b1 = bi1.equals(bi2);

    // compare bi1 with an object value 123, which is not a BigIntger
    Boolean b2 = bi1.equals("123");

    System.out.println(b1);
    System.out.println(b2);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger