Loading... # LinkedHashMap 概述 java.util.LinkedHashMap<k,v>集合 extends HashMap<k,v>集合 **LinkedHashMap的特点:** 1. LinkedHashMap集合底层是**哈希表+链表**(保证迭代的顺序):查询速度快 2. LinkedHashMap集合是一个**有序**的集合,存储元素和取出元素的顺序是一致的 Demo: ``` HashMap<String,String> map = new HashMap<>(); map.put("a","a"); map.put("c","c"); map.put("b","b"); map.put("a","d"); System.out.println(map);// key不允许重复,无序 {a=d, b=b, c=c} LinkedHashMap<String,String> linked = new LinkedHashMap<>(); linked.put("a","a"); linked.put("c","c"); linked.put("b","b"); linked.put("a","d"); System.out.println(linked);// key不允许重复,有序 {a=d, c=c, b=b} ``` > 转自: https://www.cnblogs.com/niujifei/p/11443934.html Last modification:December 14, 2020 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 感谢大佬投喂 啾咪~