Образец
@Override
public boolean equals(Object other) {
if (!(other instanceof Point)) { // 1. is it even a Point?
return false;
}
Point p = (Point) other; // 2. now it is safe to convert
return x == p.x && y == p.y; // 3. compare the contents
}
Miss the first step and passing a String crashes the program. Write public boolean equals(Point other) instead, and you have not overridden anything — you have added a second, unrelated method, and the library will keep calling the old one.
Once equals is right, list.contains(...) and list.indexOf(...) start working with your objects, because they use equals internally.