HashMapemails = new HashMap ();
//方法一: 用entrySet()
Iterator it = emails.entrySet().iterator();
while(it.hasNext()){
Map.Entry m=(Map.Entry)it.next();
System.out.println("email-" + m.getKey() + ":" + m.getValue());
}
// 方法二:直接再循环中
for (Map.Entrym : emails.entrySet()) {
System.out.println("email-" + m.getKey() + ":" + m.getValue());
}
// 方法三:用keySet()
Iterator it = emails.keySet().iterator();
while (it.hasNext()){
String key=(String)it.next();
System.out.println("email-" + key + ":" + emails.get(key));
}
emails.forEach((k, v)->System.out.println(k +" : "+v);