Answer:
indexOf returns 2
Details
Things are getting a little complicated. It would be good to look at some details.
- An
ArrayListof entries is constructed - Several
Entryobjects are put into the list. - A target
Entryobject is created. - The
indexOf()searches for the target in the list.- The
equals(Object)method ofEntryis used. - The picture shows the third comparison (which returns true).
- The
- A match is found at cell number 2
The indexOf(Object) method is a member of the ArrayList,
but it uses the equals(Object) method of Entry.
QUESTION 25:
Would playing with the program help?