> For the complete documentation index, see [llms.txt](https://yangsx95.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yangsx95.gitbook.io/notes/programming-language/java/ji-he/map/hashtable.md).

# HashTable

HashTable和HashMap的用法基本没有什么区别，但是：

1. HashTable的方法都是线程安全的，所以效率较低

   ![image-20220304091419479](https://2351062869-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7b2CdwBN9liniVJpfEAc%2Fuploads%2Fgit-blob-b9b3ff50cf627f83cd4508a4cd8843a7d0bb56cf%2Fimage-20220304091419479.png?alt=media)
2. HashMap的key可以存入空值，而且null key也遵循唯一的特点，而HashTable不能存入空值
