add integer to biginteger java code example
Example 1: java int to biginteger
// Primitive int
int myInt = 10
BigInteger bigInt = BigInteger.valueOf(myInt);
// Integer object
Integer integer = Integer.valueOf(myInt);
BigInteger bigInt = BigInteger.valueOf(myInteger.intValue());
bigInt = BigInteger.valueOf(myInteger); // works too
Example 2: java biginteger add
import java.math.BigInteger;
BigInteger num1 = new BigInteger("someNumber");
BigInteger num2 = new BigInteger("someNumber");
BigInteger result = num1.add(num);