Why does HashMap#containsKey take an parameter of type Object?
<p>A coworker encountered a bug where HashMap#containsKey was used to verify if a key-value pair exists.  The specified key was a different type so the method would always return false.  For example (Let's assume the map is populated with objects that he wants to retrieve):</p>

<p><code>Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();<br>
Long value = new Long(12);<br>
boolean hasString = map.containsKey(value);</code></p>

<p>My question is:</p>

<p><strong>Why does the Map implementation force you to put keys of type K and values of type V, but the containsKey() method allow you specify any object?</strong>  </p>

<p>There are other methods in the Map interface such as get() that also accept a parameter of type Object.</p>
