January 2014
Intermediate to advanced
736 pages
70h 43m
English
Our next application (Figs. B.9–B.10) contains a class named Account (Fig. B.9) that maintains the balance of a bank account. A typical bank services many accounts, each with its own balance, so line 7 declares an instance variable named balance of type double. It’s an instance variable because it’s declared in the body of the class but outside the class’s method declarations (lines 10–16, 19–22 and 25–28). Every instance (i.e., object) of class Account contains its own copy of balance.
1 // Fig. B.9: Account.java 2 // Account class with a constructor to validate and 3 // initialize instance variable balance of type double. 4 5 public class Account ...
Read now
Unlock full access