advancedCollections240 of 436

Why doesn't ConcurrentHashMap allow null keys/values?

Tests whether you know the reason is concurrency-specific ambiguity -- in a map accessed by multiple threads, get(key) returning null could mean either 'the key isn't present' or 'the key maps to null,' and that ambiguity is unresolvable without external locking, which defeats the point of a concurrent collection.

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