I am thinking of a hash function for any Java exercise objects. A naive way would be to call the hashCode () function for each attribute, add these hashes, and then take the sum modulo the maximum hash value or something like that. However, this will mean that the hash value will change when attributes change, therefore this method cannot be used if you want to store objects in a hash table. The hash code of the object must represent its identifier. But how can I express this abstract identity as a whole value? Perhaps using the address of the object (suppose Java does not move objects in memory at run time), but is there a way in Java to get the address of objects?
How would you implement such a hash function?
Thanks in advance.
j0ker source share