Posted By:
Robert_Lybarger
Posted On:
Friday, February 29, 2008 07:47 PM
... but in this particular case, here's what the java api docs say, in the Map interface:
Returns true if this map contains a mapping for the specified key.
More formally, returns true if and only if this map contains a mapping for a key k such
that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)
So it doesn't care *what kind* of object is put in there, it just uses the "equals" method for comparison (although I would be surprised if there is not also a quick "==" check as a performance optimization). This means that one sometimes needs to be aware of just what "equals" means to certain classes whose objects are used as keys in a map.