Why do contains()/indexOf() in a Java collections use o.equals(e) and not e.equals(o)?

Posted by Fernando on Stack Overflow See other posts from Stack Overflow or by Fernando
Published on 2010-05-27T15:38:54Z Indexed on 2010/05/27 16:01 UTC
Read the original article Hit count: 197

Filed under:
|
|

Why are the methods contains() and indexOf() in the Java collections framework defined using o.equals(e) and not e.equals(o) (where o is the argument of the methods and e is the element in the collection)?

Anyone know the reasons of that?

© Stack Overflow or respective owner

Related posts about java

Related posts about collections