Is it possible to do +- operations like this somehow?
BigInteger a = new BigInteger("1");
BigInteger b = new BigInteger("2");
BigInteger result;
a+=b;
//result = a.add(b);
Is it possible to do +- operations like this somehow?
BigInteger a = new BigInteger("1");
BigInteger b = new BigInteger("2");
BigInteger result;
a+=b;
//result = a.add(b);
In a word, no. There is no operator overloading in Java, and BigInteger is not one of the special types for which there is compiler magic to support operators such as + and +=.
Unfortunately not. Operator overloading is not supported in the Java language. The syntax only works for the other numeric primitive wrappers via auto-boxing, which wouldn't make sense for BigInteger as there's no equivalent primitive.
Nope. BigIntegers are immutable, so you can't change the value of a after creating it. And the usual mathematical operators don't work on them either, so you can't do a += b either.
You'd need to do what you have commented-out there -- result = a.add(b);