I know that hashmap actually uses hashcode to store and retrieve an object from hashtable, but my doupt is the hash code that it uses. In fact, the map contains a hash code for the key and hashcode for its value. consider this method
Map<String,String> student=new HashMap();
student.put("name", "foo");
System.out.println("name".hashCode());
System.out.println("foo".hashCode());
Here hashcode for name (key) - 3373707 hashcode for foo (value) - 101574
my doupt is the one that it should use to store and retrieve an object from hashtable
source
share