LinkedHashMap的accessOrder

Explanation of accessOrder

code demo

    @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}

If accessOrder is true, the visited elements will be placed after the linked list, and the order of placement is the order of access.
If accessOrder is false, it will be traversed in insertion order

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324775840&siteId=291194637