HashTable vs HashMap vs TreeMap
- HashMap是HashTable的輕量級實現(非線程安全),HashMap能夠經過collections.synchronizedMap()來達到同步效果。
- HashTable:contains,HashMap:containsKey、containsValue
- HashMap容許有一條記錄的鍵爲null,HashTable不容許。
- HashTable中hash數據默認大小爲11,增長方式是old*2+1。在HashMap中,hash數組的默認大小是16,並且必定是2的指數。
- hash值的使用不一樣,HashTable直接使用對象的hashCode
- TreeMap實現SortMap接口,把保存的記錄按鍵來排序。
歡迎關注本站公眾號,獲取更多信息