O'Reilly logo

Java™ How To Program (Early Objects), Tenth Edition by 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

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.

 1   // Fig. 3.8: Account.java 2   // Account class with a double instance variable balance and a constructor 3   // and deposit method that perform validation. 4  5   public class Account 6   { 7      private String name; // instance variable 8      private double balance; ...

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