hashCode used to obtain the hash code of the object, in order to know in which HashMap bucket this object should be placed. Thus, it must be an instance method of an object and it must be called polymorphic.
null can be used as a key in HashMap, but it is considered as a special case.
It seems you are using hashCode for another purpose, so you have to handle a specific path.
Jb nizet
source share