Understanding Java's Hashtable: how does it work when the keys are primitive types that hold a relationship to the values being stored?
Posted on 2003-10-23
In the java implementation of Hashtable, why is the key an object and not a hashcode (hashcode being a primitive type int)? Furthermore, in Hashtable's comments it states:
* To successfully store and retrieve objects from a hashtable, the
* objects used as keys must implement the <code>hashCode</code>
* method and the <code>equals</code> method. <p>
How does this apply when the key is assumed to be an int ? Can one assume that for a key, of primitive type int, that hashcode and equals methods need "not" be implemented?
Is not a non-java specific Hashtable normally assumed to take a key that is the hashcode of the related value to be stored/retrieved?
In my case I want the hashcode to hold a relationship to the value being stored/retireved (i.e. a checksum).