java data structures - a hash table (the HashTable)

Hash table provides a fast insertion and lookup operations, each element is a key-value pairs based on the array to achieve.

A, Java the HashMap and Hashtable difference:

HashMap can tolerate null keys and values, while Hashtable does not.

Hashtable is thread-safe, thread synchronization is achieved by synchronized. The HashMap is not thread-safe, but faster than Hashtable.

Both classes have a lot of different places, following a partial list:

a) Hashtable legacy JDK 1 is based, and is later increased HashMap.

b) Hashtable is synchronized (synchronized), and slow, but HashMap is not synchronized strategy, it will be faster.

c) Hashtable does not allow an empty key, but HashMap allowed a null key.

 

references:

https://www.cnblogs.com/aeolian/p/8468632.html

https://www.cnblogs.com/williamjie/p/9099141.html

http://www.luyixian.cn/news_show_10979.aspx 

Guess you like

Origin www.cnblogs.com/hardhp74520/p/11324379.html