accessOrder的解释
代码演示
@Test
public void fun2() throws Exception {
LinkedHashMap<String, String> accessOrderTrue = new LinkedHashMap<>(16, 0.75f, true);
accessOrderTrue.put("1","1");
accessOrderTrue.put("2","2");
accessOrderTrue.put("3","3");
accessOrderTrue.put("4","4");
System.out.println("acessOrderTure"+accessOrderTrue);
accessOrderTrue.get("2");
accessOrderTrue.get("3");
System.out.println("获取了数据"+accessOrderTrue);
}
//控制台输出
acessOrderTure{1=1, 2=2, 3=3, 4=4}
获取了数据{1=1, 4=4, 2=2, 3=3}
如果accessOrder为true的话,则会把访问过的元素放在链表后面,放置顺序是访问的顺序
如果accessOrder为flase的话,则按插入顺序来遍历