//constructors CheckingAccount( String accNumber, String holder, int start ) { accountNumber = accNumber ; accountHolder = holder ; balance = start ; }
We have enough code to put together a test program. The test program will not do much, but it will compile and run.
class CheckingAccount { // instance variables String accountNumber; String accountHolder; int balance; //constructors CheckingAccount( String accNumber, String holder, int start ) { accountNumber = accNumber ; accountHolder = holder ; balance = start ; } // methods } class CheckingAccountTester { public static void main( String[] args ) { CheckingAccount account1 = new CheckingAccount( "123", "Bob", 100 ); System.out.println( account1.accountNumber + " " + account1.accountHolder + " " + account1.balance ); } }
This program can be copied to a file, compiled, and run in the usual way. The output will be:
C:\chap32>java CheckingAccountTester 123 Bob 100
What does the expression
account1.accountNumber
mean?
(Look in the println
statement to see where this
expression was used.)