Re: HashMap get/put



On 10/28/2009 05:59 PM, Wojtek wrote:
Or rather, why does the spec not say get(K key) instead of get(Object o)

I can think of some cases where it might be desirable to use gets with other objects; this requires, of course, that the objects be designed with this use case in mind, namely that the hash codes and equals work correctly.

One example that came up in some code was where I had a parameter accessible in two different fashions, and the conversion between the two forms became a hotspot in the code.

--
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
.