Java BigInteger.hashCode()

Syntax

BigInteger.hashCode() has the following syntax.

public int hashCode()

Example

In the following code shows how to use BigInteger.hashCode() method.


/*  w  w  w  .j  a va 2 s.c  o m*/
import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

    // assign values to bi1, bi2
    BigInteger bi1 = new BigInteger("12345");
    BigInteger bi2 = new BigInteger("987654321");

    // assign the hashcode of bi1, bi2 to i1, i2
    int i1 = bi1.hashCode();
    int i2 = bi2.hashCode();

    System.out.println(i1);
    System.out.println(i2);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger