If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
This I read from following link
http://www.jusfortechies.com/java/core-java/hashcode.php.
I have read similar kins of statement before also. This is very confusing for me. If there are two objects on the heap then each one of them has unique HashCode. If both these objects are equal, then values of their fields are equal, which are compared by overriding equals(). But still they are different objects and have different hashcode values. So what does this statement mean that "hashCode method on each of the two objects must produce the same integer result." ?
I asked similar question before also, but did not get satisfactory replies.
My simple understanding is "for two objects on heap their hash code values are unique, irrespective of their field values. If two objects have same hash code value then that means both references are pointing to same object on heap"
Please correct me if I am wrong.