3.5.1 Account Class with a balance Instance Variable of Type double
Our next app contains a version of class Account
(Fig. 3.8) that maintains as instance variables the name
and the balance
of a bank account. A typical bank services many accounts, each with its own balance, so line 8 declares an instance variable balance
of type double
. Every instance (i.e., object) of class Account
contains its own copies of both the name
and the balance
.
Get Java™ How To Program (Early Objects), Tenth 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.