posted 22 years ago
I've recently read a chapter on this. My understanding with implementing hashCode() is that you take a look at the equals method and see which member variables are being used to compare the "value" of the instance of the class, and then create a hashCode implementation like: a+b.
Now, I've been out of college for about 4 years, so my CS knowledge is not quite as sharp, but I was surpised to learn that a valid hashcode could also just be a constant, just "return 123;", but this would not be "efficient" because then every object would have the same hashcode, and I guess that this means when hashing your objects you won't get a good distribution in a Hashtable.