If you look at the source code of BigInteger, you will see an overload method for adding long number value. But they also mentioned it in method description that the method is private. That's why you could not be able to call it from your class.
/**
* Package private methods used by BigDecimal code to add a BigInteger
* with a long. Assumes val is not equal to INFLATED.
*/
BigInteger add(long val) {
if (val == 0)
return this;
if (signum == 0)
return valueOf(val);
if (Long.signum(val) == signum)
return new BigInteger(add(mag, Math.abs(val)), signum);
int cmp = compareMagnitude(val);
if (cmp == 0)
return ZERO;
int[] resultMag = (cmp > 0 ? subtract(mag, Math.abs(val)) : subtract(Math.abs(val), mag));
resultMag = trustedStripLeadingZeroInts(resultMag);
return new BigInteger(resultMag, cmp == signum ? 1 : -1);
}
Btw, as we all know the compiler uses valueOf() method to convert primitive value to Object (Unboxing). And Java automatic convert object to primitive object.longValue() (Autoboxing).
BigInteger iObject = BigInteger.valueOf(2L);
long iPrimitive = iObject.longValue();
I am sure that you already knew how to use it with BigInteger add method in this case for long value.
BigInteger b = new BigInteger("2000");
b.add(BigInteger.valueOf(2L));