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

后端 未结 30 3064
青春惊慌失措
青春惊慌失措 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:52

    Hashtable is synchronized, whereas HashMap isn't. That makes Hashtable slower than Hashmap.

    For single thread applications, use HashMap since they are otherwise the same in terms of functionality.

提交回复
热议问题