What are the differences between HashMap and Hashtable?

8

What are the differences between HashMap and Hashtable in Java?

Which is more efficient?

    
asked by anonymous 25.08.2015 / 21:20

1 answer

11

Hashmap

  • Not synchronized
  • Accepts nulls and a null key
  • You can sweep entire structures with a simple iterator
  • It has containsValue() and containsKey()
  • It's faster
  • Consume less memory
  • More modern
  • Mother: AbstractMap

Hashtable

  • Synchronized and can be easily used in concurrent environment
  • Do not accept nulls
  • Iterar is more complicated
  • It has contains()
  • Has overhead by synchronization
  • Holds more memory
  • Deprecated
  • Mother Dictionary

I removed the information mainly from this answer in the SO .

    
25.08.2015 / 21:31