In a HashMap
, if I put custom objects as a key.
What would happen if I override
hashCode()
method and implement it to pass value as \'1
Adding Math.random() doesn't affect much performance hit but it is a bad idea to construct hashcode values through random() function. Instead you can use some of the good hashing function to minimize the collision and which are much faster also. For reference you can check out some of the links http://www.partow.net/programming/hashfunctions/