使用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());
}