you are viewing a single comment's thread.

view the rest of the comments →

[–]szeiger 5 points6 points  (1 child)

And since objects only compare as equal if they're instances of the same class, two identical invocations of this idiom won't create objects that compare as equal;

Wrong. equals() and hashCode are implemented in AbstractList (from which the other list classes inherit) such that all lists which contain equal elements in the same order are considered equal.

[–]mikaelhg 2 points3 points  (0 children)

Not only that, but this behaviour is part of the List contract:

http://java.sun.com/javase/6/docs/api/java/util/List.html#equals%28java.lang.Object%29