... multiply, add and pow. The expression in line 19 evaluates as follows:
-
First, the expression
rate.add(BigDecimal.ONE)adds1to therateto produce aBigDecimalcontaining1.05—this is equivalent to1.0 + ratein line 15 of Fig. 5.6. TheBigDecimalconstantONErepresents the value1. ClassBigDecimalalso provides the commonly used constantsZERO(0) andTEN(10). -
Next,
BigDecimalmethodpowis called on the preceding result to raise1.05to the poweryear—this is equivalent to passing1.0 + rateandyearto methodMath.powin line 15 of Fig. 5.6. -
Finally, we call
BigDecimalmethodmultiplyon theprincipalobject, passing the preceding result as the argument. This returns aBigDecimalrepresenting the amount on deposit at the end of the specified ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access