Java Reference
In-Depth Information
Figure 8
The Implicit Parameter of a Method Call
108
109
S ELF C HECK
15. How many implicit and explicit parameters does the withdraw
method of the BankAccount class have, and what are their names and
types?
16. In the deposit method, what is the meaning of this.amount ? Or,
if the expression has no meaning, why not?
17. How many implicit and explicit parameters does the main method of
the BankAccount-Tester class have, and what are they called?
C OMMON E RROR 3.2: Trying to Call a Method Without
an Implicit Parameter
Suppose your main method contains the instruction
withdraw(30); // Error
The compiler will not know which account to access to withdraw the money. You
need to supply an object reference of type BankAccount :
BankAccount harrysChecking = new BankAccount();
harrysChecking.withdraw(30);
Search WWH ::




Custom Search