发布网友 发布时间:2022-04-24 00:37
共2个回答
热心网友 时间:2023-10-15 20:37
HashMap<String, String> emails = new HashMap<String, String>();
//方法一: 用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.Entry<String, String> m : 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));
}
热心网友 时间:2023-10-15 20:38
emails.forEach((k, v)->System.out.println(k +" : "+v);
热心网友 时间:2023-10-15 20:37
HashMap<String, String> emails = new HashMap<String, String>();
//方法一: 用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.Entry<String, String> m : 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));
}
热心网友 时间:2023-10-15 20:38
emails.forEach((k, v)->System.out.println(k +" : "+v);