Two Point objects with the same coordinates are not ==, because == checks whether both references point to the same object. Overriding equals() lets you compare by value, and hashCode() must be overridden with it so that HashMap and HashSet find equal objects. Do this for any class you use as a map key or put in a set. Overriding only equals() is the classic bug: contains can return false for an object you just added.