LinkedHashMap存入与取出

 @Test
    public void LinkedHashMap() {

        Map map = new LinkedHashMap<>();
        map.put("1key", "1value");
        map.put("2key", "2value");
        map.put("3key", "3value");
        Iterator it = map.entrySet().iterator();
        System.out.println("依照加入顺序打印map");
        while (it.hasNext()) {
            Map.Entry entity = (Map.Entry) it.next();
            System.out.println(entity);
        }
    }

执行结果

依照加入顺序打印map
1key=1value
2key=2value
3key=3value

你可能感兴趣的:(java)