I have a small question about Java Hashmap
. If I override the hashCode
method such that:
@Override
public int hashCode(){
return
Hashcode values are used to reduce the search time of an object . The hashcode value does not necessarily be unique for distinct objects. The hashCode() method may in fact, be overridden in such a way that it returns a constant integer for all objects (this would however defeat the purpose of hashCode() method). However, the default implementation of class Object does return a unique integer for every object, as it maps the internal address of the object to an integer and returns the same. But this is not a requirement