I want to compare two lists. Since we code to interface using
Even though the
List interface does not contain an
equals method, the list-classes may (and does) still implement the
From the API docs on
AbstractList (inherited by for instance
public boolean equals(Object o)Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal.
The same applies to for instance the
hashCode method and so on.
As @Pascal mentions in the comments, the List interface mentions the
equals method and states the following in the documentation:
The List interface places additional stipulations, beyond those specified in the Collection interface, on the contracts of the iterator, add, remove, equals, and hashCode methods.