Understand Java hasCode() method

Understand Java hasCode() method
1. definintion in java.lang.Object
   public native int hashCode();
   keyword 'native' indicates the mothod is implemented directly in the native code in the JVM.
   it is a 32-bit signed integer.
2. questions

   Why choose a prime number as the number of slots for hashing function that uses divison method?

   Why does Java's hashCode() in String use 31 as a multiplier?

   Why use a prime number in hashCode?

你可能感兴趣的:(Understand Java hasCode() method)