How to Iterate Map
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了How to Iterate Map相关的知识,希望对你有一定的参考价值。
常用iterate 方法
1 Map<Integer, String> m = new HashMap<Integer, String>(); 2 for(Map.Entry<Integer, String> entry : m.entrySet()){ 3 System.out.println("Key: " + entry.getKey() + ", Value: " + entry.getValue()); 4 } 5 6 7 Iterator<Map.Entry<Integer, String>> iterator = m.entrySet().iterator(); 8 while(iterator.hasNext()){ 9 Map.Entry entry = iterator.next(); 10 System.out.println("Key: " + entry.getKey() + ", Value: " + entry.getValue()); 11 }
以上是关于How to Iterate Map的主要内容,如果未能解决你的问题,请参考以下文章
How to directly initialize a Map/List/Set
How to directly initialize a Map/List/Set
how to add borders for a google map marker 谷歌地图 自己定义图钉
How do I iterate over a Scala List (or more generally, a sequence) using theforeach method or for lo