Why Object#hashCode() returns int instead of long

Because the maximum length of an array is Integer.MAX_VALUE.

Since the prime use of hashCode() is to determine which slot to insert an object into in the backing array of a HashMap/Hashtable, a hashcode > Integer.MAX_VALUE would not be able to be stored in the array.

Leave a Comment