Java Data Type Tutorial - Java BigInteger.intValue()








Syntax

BigInteger.intValue() has the following syntax.

public int intValue()

Example

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

//from ww w  .  j a  v  a 2s  . 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("123");
    BigInteger bi2 = new BigInteger("987654321");

    // assign the integer values of bi1, bi2 to i1, i2
    Integer i1 = bi1.intValue();
    Integer i2 = bi2.intValue();

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

The code above generates the following result.