So: Any two Lists (of any type) containing equal
elements in the same order will have equal hashCodes if
their hashCode() methods are implemented as called for.
Also, any two Sets (of any type) containing equal elements
should have equal hashCodes. But equality doesn't hold
across different interfaces: A List with elements x,y,z
most likely has a different hashCode than a Set of x,y,z.
Just to clairify:
A List can never equal a Set, even if they contain the same elements
they are NOT the same (since the Set lacks the order information).
Cut from Collection's JavaDoc:
The general contract for the Object.equals method states that equals
must be symmetric (in other words, a.equals(b) if and only if
b.equals(a)). The contracts for List.equals and Set.equals state that
lists are only equal to other lists, and sets to other sets. Thus, a
custom equals method for a collection class that implements neither
the List nor Set interface must return false when this collection is
compared to any list or set. (By the same logic, it is not possible to
write a class that correctly implements both the Set and List
interfaces.)
Read more on List and Set if this is not enough proof :-)
/Olle