O'Reilly logo

Android™ How to Program, Second Edition by Abbey Deitel, Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Account Class with an Instance Variable of Type double

Our next application (Figs. B.9B.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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required