[Solved] Why is .contains returning false when I add a duplicate? [closed]

See the documentation of List#contains given below: Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that Objects.equals(o, e). Thus, you need to override equals method in class City. You can do it as follows: @Override public boolean … Read more