Originally posted by Jim Baiter:
I am overriding equals() in some classes that will be
frequently used so I am looking for the best performing
hashCode() to use?
Why do you need hashCode() to implement equals()? I thought you just needed hashCode() if you wanted to stick your objects into a HashMap.
If I have a class with several members,
should I just use the XOR of the hashCode()'s for those
members?
That should usually be quite effective. The only exception I can think of is an aggregate with multiple, identical member objects that each have a limited set of values. That wouldn't work for the same reason XORing the characters in a
string won't work.
- Peter