The hash code of the object and its address in memory are not related in any way. It is simple that various implementations of objects (in different languages, actually) use the memory address of the object as a unique way of identifying this object.
In general, a pair of hashCode and equals methods provide a means to compare objects for identification. When implementing your own hash scheme, you should keep in mind that the hash value must consist of something that makes the object unique. For example, imagine that you provide a mapper object to a database system and want to present a Customer object - you know that in your table clients are unique with respect to their primary key, so returning this primary key as a hash code will be perfectly acceptable and in no way not associated with the memory address of the object.
If the client is identified using his first name, last name and date of birth (which is really not enough to uniquely identify the person, but let him be simple for brevity), you can use these 3 values ββin the code hash and use it in the implementation of O / R matching.
source share