In the example two bigdecimal objects obj_0 and obj_1 values are added and the result is stored in object obj_3. Also the addition result of objects obj_4 & obj_5 are stored in object obj_6. Object obj_6 contains addition result as per context settings defined under MathContext class objects mc and nc respectively.
Syntax for using add method :
public BigDecimal add(BigDecimal augend),
public BigDecimal add(BigDecimal augend, MathContext mc)
Scale associated to the result is computed through bigdecimal class max method. .max() method compares the this.object scale with the scale of the object specified & returns scale which maximum!greater.
In the example for formating purpose two new classes NumberFormat
& Locale are included.
Method throws NumberFormatException if it finds a value other than a integer or double value.
Recommend the tutorial