HashMap的遍历(利用key获取value)

package study;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class better {
public static void main(String[] args){
Map map=new HashMap();
map.put(“201901”,“chen”);
map.put(“201902”, “huang”);
map.put(“201903”, “zhang”);
Set keys=map.keySet();
for (String key : keys) {
String value=map.get(key);
System.out.println(key+"—"+value);
}
}
}
HashMap的遍历(利用key获取value)_第1张图片

你可能感兴趣的:(代码)