What is the difference between `WeakHashMap` and a regular `HashMap` with `WeakReference` values?

Java Hard
Select the correct answer: Single Choice

Key points

  • WeakHashMap removes entries when keys are garbage collected
  • Regular HashMap with WeakReference values keeps keys alive
  • Key distinction: automatic entry removal in WeakHashMap

Ready to go further?