What are the differences between a HashMap and a Hashtable in Java?

后端 未结 30 2365
青春惊慌失措
青春惊慌失措 2020-11-21 13:30

What are the differences between a HashMap and a Hashtable in Java?

Which is more efficient for non-threaded applications?

30条回答
  •  一向
    一向 (楼主)
    2020-11-21 13:51

    HashTable is a legacy class in the jdk that shouldn't be used anymore. Replace usages of it with ConcurrentHashMap. If you don't require thread safety, use HashMap which isn't threadsafe but faster and uses less memory.

提交回复
热议问题