遍历MAP

Map m=new HashMap();
m.put("a","1");
m.put("b","2");
m.put("c","3");

Set test = m.entrySet();
Iterator testkey = test.iterator();
while(testkey.hasNext()){
    Entry testEntry = (Entry) testkey.next();
    String key = testEntry.getKey().toString();
    String value = (String) testEntry.getValue();
    System.out.println("key="+key);
    System.out.println("value="+value);
    System.out.println("");
}

你可能感兴趣的:(C++,c,C#)