遍历Map集合

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了遍历Map集合相关的知识,希望对你有一定的参考价值。

HashMap<String, String> map = new HashMap<String, String>();
        map.put("京东", "刘强东");
        map.put("腾讯", "马化腾");
        Set<Map.Entry<String, String>> entrySet = map.entrySet();
        Iterator<Map.Entry<String, String>> iterator = entrySet.iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> entry = iterator.next();
            System.out.println("主键:" + entry.getKey() + ",值:" + entry.getValue());
        }

 

以上是关于遍历Map集合的主要内容,如果未能解决你的问题,请参考以下文章