Search code examples
javabigdecimal

BigDecimal += (add and assign) ...How to do this?


I can't seem to locate an 'add and assign' method in the BigDecimal class.

Is there a method for this?

In case you don't understand my question I'm trying to do this:

a += b;

but I'm trying to do it with BigDecimals


Solution

  • There is an add method in the BigDecimal class.

    You would have to do - a = a.add(b);

    Have a look at the java docs.