Adding a Method Definition
¥class
Entry {
¥ É
¥ /** return this if its name matches
keyName; otherwise return null indicating failure */
¥
Entry match(String keyName) {
¥
if (keyName.equals(this.name)) return this;
else return
null
¥ }
¥}
¥
Finger Exercise: Add this method definition to your Entry class, compile it, and
evaluate:
¥
Entry e = new Entry("Corky", "DH 3104", "x
6042");
e.match("Corky")
¥
e.match("Matthias")
¥