advancedCollections219 of 436

HashMap has 1 million entries. Performance is degrading. Why, and how would you resolve it?

Tests whether you check the initial capacity/load factor first -- an undersized initial capacity forces repeated resize-and-rehash cycles as the map grows to a million entries, and the fix is pre-sizing the map to its expected final size instead of letting it grow incrementally from the default 16.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

← Back to all Core Java questions