LinkedHashMap与HashMap的区别
时间: 2023-10-26 11:01:17 浏览: 92
LinkedHashMap与HashMap的区别在于LinkedHashMap在继承了HashMap的大部分功能之外,还具有排序的功能。具体来说,LinkedHashMap使用双向链表来保证元素的顺序,而HashMap则没有这个功能。另外,LinkedHashMap新增了三个属性,分别是head(链表的头部)、tail(链表的尾部)和accessOrder(迭代顺序标识)。所以,LinkedHashMap可以按照插入顺序或者访问顺序来迭代元素,而HashMap只能按照哈希表的存储顺序来迭代元素。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [HashMap与LinkedHashMap有什么区别](https://blog.csdn.net/qq_32379477/article/details/111499834)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [LinkedHashMap和hashMap的区别](https://blog.csdn.net/qq_31338839/article/details/125716749)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文