View Full Version : What is hashCode?

06-10-2016, 04:23 AM
What is hashCode?

Shivangi Panwar
07-27-2016, 11:26 PM
Hash Code is used for bucketing in hash implementation like hashmap, hashtable, hashset...

07-31-2016, 10:11 PM
Hash code is a code that identifies each object,not necessarily unique hash code is generally used for comparing objects, if two object of same type can have same hash code they said to be equal hash code is integer value this would be automatically generated by JVM.

02-16-2017, 02:37 AM
Hi, HashCode is a mathematical formula that returns some integer value. This integer value is used as index in array.


secdevops (https://www.checkmarx.com/2015/06/22/21-awesome-talks-and-resources-on-security-and-devops/)

02-20-2017, 12:10 AM
A hashcode is a number generated from any object. This is what allows objects to be stored/retrieved quickly in a Hashtable. Imagine the following simple example: On the table in front of you you have nine boxes, each marked with a number 1 to 9.

Thank you~


03-14-2017, 12:21 AM
HashCode is a mathematical formula(there is no best hash function) that returns some integer value.
This integer value is used as index in array.
hashCode(int value){

/*Some hash function computation goes here*/
return hash;

The hash is returned and now it acts as the index of the array. The value is inserted in that place. Now if you want to retrieve that value then you again use hashCode(val) and get the hash of value and directly take that value from index of array.

Well what happens if hashCode(val) returns index where the value is already inserted. This is called collision and some collision handling strategy is used(example separate chaining).

Qualities of good hash function
For same value the Hash function should return same hash
hash function should distributed the hash evenly across the array.