![]() |
![]() |
|
home—info—lects—labs—exams—hws
textbook—tutor/PIs—java.lang docs—java.util docs
We will talk about how somebody might want to use an BankAccount object (that is, what behaviors BankAccounts should have, which becomes “We'll make a class BankAccount; what methods should we have?”
We'll talk about the signature for a method; this will be the other thing you'll need to memorize:
typereturn name( parameter-type-and-name )
(If we have time:)
The problem with just writing, say,
public double getBalance() {
...
}
|
public double getBalance() {
return -12.345;
}
|
Of course, if a method's signature says it returns a String, then our stub function must comply:
public String getOwnerName() {
return "John Jacob Jinklheimerschmidt";
}
|
What about void methods, that don't return a value at all? You can leave those empty:
public void deposit() {
}
// This compiles as-is.
|
home—info—lects—labs—exams—hws
textbook—tutor/PIs—java.lang docs—java.util docs
| ©2009, Ian Barland, Radford University Last modified 2009.Feb.09 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarland |
![]() |