PrepZone Logo
PrepZone
Back to Java

Java · Hard

How and when does a HashMap resize? What is rehashing and what is its time complexity?

JavaCollections

Answer preview

HashMap resizes (rehashes) when the number of entries exceeds capacity × load factor. Resize doubles the bucket array and re-distributes all entries.…