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 ?

snehal
  • 1,798
  • 4
  • 17
  • 24
  • 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. – Peter Lawrey Feb 22 '14 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. – TypeIA Feb 22 '14 at 13:07

0 Answers0