Instance variables are used to store the state of an object. They hold values for as long as the object exists.
The formal parameters of a method can be seen only by the statements of their own method. This means that if a method tries to use a parameter of some other method, the compiler will find a syntax error.
Here is the
CheckingAccount
class again,
this time with a new definition of the
toString()
method
class CheckingAccount { . . . . private int balance; . . . . public void processDeposit( int amount ) { return "Account: " + accountNumber + "\tName: " + accountHolder + "\tBalance: " + amount + "\tUse Count: " + useCount; } // modified toString() method public String toString() { System.out.println( balance + "\t" + amount ); } }
Is this toString()
method correct?