... multiply, add and pow. The expression in line 19 evaluates as follows:

  1. First, the expression rate.add(BigDecimal.ONE) adds 1 to the rate to produce a BigDecimal containing 1.05—this is equivalent to 1.0 + rate in line 15 of Fig. 5.6. The BigDecimal constant ONE represents the value 1. Class BigDecimal also provides the commonly used constants ZERO (0) and TEN (10).

  2. Next, BigDecimal method pow is called on the preceding result to raise 1.05 to the power year—this is equivalent to passing 1.0 + rate and year to method Math.pow in line 15 of Fig. 5.6.

  3. Finally, we call BigDecimal method multiply on the principal object, passing the preceding result as the argument. This returns a BigDecimal representing the amount on deposit at the end of the specified ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.