public class ceshi3 {
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
map.put("01", "山东");
map.put("02", "菏泽");
map.put("03", "曹县");
//增强for遍历
Set<String> set = map.keySet();
for(String key:set){
System.out.println("增强for:"+map.get(key));
}
//迭代器
Iterator<String> it = set.iterator();
while(it.hasNext()){
String key = it.next();
System.out.println("迭代器:"+map.get(key));
}
//entrySet()遍历出来是key-value
for(Map.Entry<String, String> entry:map.entrySet()){
System.out.println("entrySet:"+entry.getKey()+"\t"+entry.getValue());
}
//Values()只能获取value
for(String value:map.values()){
System.out.println("Values:"+value);
}
}
}