posted 18 years ago
Hi Corey,
I just read ur article on Hashcode. Its really a very good article. I just have a question on this
In the example-3 of ur article( Rule1 satisfied but Rule2 not satisfied)
, How did u say by ur example tht for equal objects the code returned different hashcodes??
Can u just brief me on this??
I think that for 2equal objects according to ur example it will return the same hashcode since the equals method in your example compares the contents and not the address.
In the method definition of ur hashcode you are just returning the difference of the values and this difference has to be same for 2 equal objects since the comparision is made by checking the contents.
Plz do comment on this.