Addition for BigDecimal
The BigDecimal
is immutable so you need to do this:
BigDecimal result = test.add(new BigDecimal(30));
System.out.println(result);
It looks like from the Java docs here that add returns a new BigDecimal:
BigDecimal test = new BigDecimal(0);
System.out.println(test);
test = test.add(new BigDecimal(30));
System.out.println(test);
test = test.add(new BigDecimal(45));
System.out.println(test);
BigDecimal test = new BigDecimal(0);
System.out.println(test);
test = test.add(new BigDecimal(30));
System.out.println(test);
test = test.add(new BigDecimal(45));
System.out.println(test);