February 2014
Beginner
1248 pages
62h 25m
English
Different accounts typically have different names. For this reason, class Account (Fig. 3.1) contains a name instance variable. A class’s instance variables maintain data for each object (that is, each instance) of the class. Later in the chapter we’ll add an instance variable named balance so we can keep track of how much money is in the account. Class Account contains two methods—method setName stores a name in an Account object and method getName obtains a name from an Account object.
The class declaration begins in line 5:
public class Account
The keyword public (which Chapter 8 explains in detail) is an access modifier. For now, we’ll simply ...
Read now
Unlock full access