An important thing to remember when using methods like
contains()
,
indexOf()
is that these sort of methods rely on using the
equals()
method to compare object types.
In your scenario, you're trying to see whether a list contains an instance of
Teacher
, so you may need to consider overriding the
equals()
method to check for equality in the objects.
This page[
^] has a good description.