public class Test{
public static void main(String[] args) {
Map<String,String> map = new HashMap<String,String>();
map.put("id1", "wang");
map.put("id2", "li");
//通过keySet
Set<String> set = map.keySet();
for(String s:set){ System.out.println(s + "," + map.get(s)); }
//通过entrySet
Set<Map.Entry<String, String>> entryseSet = map.entrySet();
for(Map.Entry<String, String> entry:entryseSet){ System.out.println(entry.getKey()+","+entry.getValue()); }
//K Iterator
Iterator<String> it = map.keySet().iterator();
while(it.hasNext()){ System.out.println(map.get(it.next())); }
//V Iterator
Iterator it = map.values().iterator();
while(it.hasNext()){
String val = (String)it.next();
System.out.println(val);
}
}
}