0

I read the Java Generics and Collection book and in that there is one statement

" prime numbers (such as 31, here) are used in calculating the hash code because multiplying by primes will not tend to shift information away from the low end."

What is the meaning of this statement, can anyone help me ?

2
  • If you use an even number the product will have a lower bit which is always 0, this is clearly not as random as it could be. The same applies for small numbers and non-primes. Commented Feb 22, 2014 at 12:59
  • The answer to this question requires some number theory knowledge... you might try asking this on math.stackexchange.com. This is a very good question though. Commented Feb 22, 2014 at 13:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.