如何遍历LinkedHashMap
使用Iterator遍历LinkedHashMap<String,String> linkedHashMap = new LinkedHashMap();linkedHashMap.put("a", "a");linkedHashMap.put("b&quo
·
使用Iterator遍历
LinkedHashMap<String,String> linkedHashMap = new LinkedHashMap();
linkedHashMap.put("a", "a");
linkedHashMap.put("b", "b");
linkedHashMap.put("c", "c");
Iterator it = linkedHashMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
System.out.println("key:" + entry.getKey() + " value:" + entry.getValue());
}
foreach循环遍历
LinkedHashMap<String,String> linkedHashMap = new LinkedHashMap();
linkedHashMap.put("a", "a");
linkedHashMap.put("b", "b");
linkedHashMap.put("c", "c");
for(Map.Entry<String, String> entry : linkedHashMap.entrySet()) {
System.out.println("key:" + entry.getKey() + " value:" + entry.getValue());
}
更多推荐
已为社区贡献1条内容
所有评论(0)