Java convert int to BigInteger
Tags: BigInteger BigInteger valueOf int
In this Java core tutorial we learn how to convert an integer value to a BigInteger value using the java.math.BigInteger.valueOf() method.
How to convert integer to BigInteger
To convert a given int value to BigInteger we can use the method java.math.BigInteger.valueOf() which instantiates a BigInteger from a given integer value.
ConvertIntegerToBigIntegerExample.java
import java.math.BigInteger;
public class ConvertIntegerToBigIntegerExample {
public static void main(String... args) {
int intValue = 905644;
BigInteger value = BigInteger.valueOf(intValue);
System.out.println("BigInteger value: " + value);
}
}
BigInteger value: 905644
Happy Coding 😊