Possible Duplicate:
Why does Java's hashCode() in String use 31 as a multiplier?
@Override public int hashCode() {
int result = 17 + hashDouble(re);
result = 31 * result + hashDouble(im);
return result;
}
This is the code from "Effective Java". Is it widely used in enterprise applications? I am concerned about adding the static values. Or should we define 17 and 31 as final variables in some sort of Utility class and reference them from there?
Also can someone explain what these numbers are for? Is 31 just a prime number chosen randomly?