zoukankan      html  css  js  c++  java
  • List<Map<String, String>>和Map<String, List<String>>遍历

    public void TestM() {

        List<Map<String, String>> lm = new ArrayList<>();
        Map<String, String> m = new HashMap<>();
        m.put("1", "chenhe");
        m.put("2", "wangchaonan");

        Map<String, String> m1 = new HashMap<>();
        m1.put("1", "xiaochenhe");
        m1.put("2", "xiaowangchaonan");
        lm.add(m);
        lm.add(m1);

        for (Map<String, String> map : lm) {
            System.out.println(map + "============");
            for (String mp : map.keySet()) {
                System.out.println(mp + "_______________" + map.get(mp));
            }
        }

        Map<String, List<String>> ml = new HashMap<>();
        List<String> l = new ArrayList();
        List<String> l1 = new ArrayList();
        List<String> l2 = new ArrayList();
        l.add("1");
        l.add("2");
        l.add("3");

        l1.add("4");
        l1.add("5");
        l1.add("6");

        l2.add("7");
        l2.add("8");
        l2.add("9");

        ml.put("1", l);
        ml.put("2", l1);
        ml.put("3", l2);

        for (String mm : ml.keySet()) {
            System.out.println(mm + "------" + ml.get(mm));
            Iterator<String> it = ml.get(mm).iterator();
            if (it.hasNext()) {
                System.out.println(ml.get(mm));
            }

            for (String mmm : ml.get(mm)) {
                System.out.println(mmm);
            }
        }
    }

  • 相关阅读:
    vue 简易弹框
    js瀑布流触底动态加载数据
    ios解决大转盘层级以及闪烁bug
    dom 相同父节点查找
    为什么 EXISTS(NOT EXIST) 与 JOIN(LEFT JOIN) 的性能会比 IN(NOT IN) 好
    exists(关联表)与left join 的效率比较
    【SpringCloud】Re04 Gateway
    【SpringCloud】Re03 Feign
    【SpringCloud】 Re02 Nacos
    【SpringCloud】 Re01
  • 原文地址:https://www.cnblogs.com/wangchaonan/p/10044430.html
Copyright © 2011-2022 走看看