Java Reference
In-Depth Information
14
int
c = firstBankOfJava.
count(threshold);
15 System.out.println(
"Count: "
+ c);
16 System.out.println(
"Expected: 2"
);
17
18
int
accountNumber =
1015
;
19 BankAccount a =
firstBankOfJava.find(accountNumber);
20
if
(a ==
null
)
21 System.out.println(
"No matching
account"
);
22
else
23 System.out.println(
"Balance of
matching account: "
24 + a.getBalance());
25 System.out.println(
"Expected: 10000"
);
26
27 BankAccount max =
firstBankOfJava.getMaximum();
28 System.out.println(
"Account with
largest balance: "
29 + max.getAccountNumber());
30 System.out.println(
"Expected: 1001"
);
31 }
32 }
305
306
Output
Count: 2
Expected: 2
Balance of matching account: 10000.0
Expected: 10000
Account with largest balance: 1001
Expected: 1001
S
ELF
C
HECK
9.
What does the
find
method do if there are two bank accounts with a
matching account number?
10.
Would it be possible to use a Ȓfor eachȓ loop in the
getMaximum
method?