Search code examples
javacollectionssizehashtablebucket

What is size of a hash-table bucket in java?


We know that more than one object with same hash code can be stored in a single bucket of a hash-table in JAVA. My question is:

What is maximum number of objects a single bucket can store?


Solution

  • It's unlimited. Whatever has the same hashCode (with the mask) goes into the same position in the hash table. It's basically linked list.

    It may cause some problems obviously as it could significantly affect the performance but usually with reasonable distribution of items it hardly happens that there are more than one or two items in single position.