A Google search did not give me any answer to this. But I feel there is logic and mathematical reasoning behind using the integer 1000003 to calculate hash codes.
For example, AutoValue will generate the following hash code for a given value class -
@Override
public int hashCode() {
int h = 1;
h *= 1000003;
h ^= this.firstName.hashCode();
h *= 1000003;
h ^= this.lastName.hashCode();
h *= 1000003;
h ^= this.age;
return h;
}
What is the reason behind this specific integer? If I use IntelliJ to create an overridden hashcode method, it uses integer 31.
Its curious to know what the authors were thinking.
Note that Why use a prime number in hashCode? is a similar question. However, that is asking about prime numbers in hash codes in general, whereas this is asking why the specific value 1000003 is used by AutoValue (as opposed to e.g. a different prime number).