Java tutorial: convert BigInteger to Integer

BigInteger is a Java class that cab be used for very large integers that is bigger than 64 bit values. BigInteger operations are substantially slower than built-in integer types. Also, you can't change the stored value of a BigInteger object.

In this tutorial I will show you how you can easily convert a BigInteger object to Integer.

I will create a new BigInteger object:

BigInteger o = new BigInteger("10000000000000000");

Next, to convert the BigInteger object to Integer, I will use intValue():

Integer new = o.intValue();

System.out.println(new);

Output:

1874919424

In this way you can easily convert BigInteger object to Integer type.









Leave a Comment