I have some simple data beans that need to override hashCode. One of you Experts gave me a simple hasCode example a while back, which I implemented like this:
public int hashCode()
int hash = 17;
hash = hash * 37 + bankID;
hash = hash * 37 + applicationCode;
hash = hash * 37 + (int) accountNbr; // this is a long
My problem is, at least on this example, accountNbr is a long, not an int. (It a ten-byte numeric.) So I'm obviously losing some precision here.
My question is: Is that a little bit bad, or just plain wrong? (If it just means less-than-optimal sorting, for instance, that's OK for my purposes.)
And if it's just plain wrong, what do I do? hashCode needs to return an int, right?