package com.bie;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class MapTest01 {
public static void main(String[] args) {
Map<String, String> map=new HashMap<String, String>();
map.put("张三1", "男");
map.put("张三2", "男");
map.put("张三3", "男");
map.put("张三4", "男");
map.put("张三5", "男");
for(String s:map.keySet()){
System.out.println("key : "+s+" value : "+map.get(s));
}
System.out.println("====================================");
for(String s1:map.keySet()){
System.out.println("键key :"+s1);
}
for(String s2:map.values()){
System.out.println("值value :"+s2);
}
System.out.println("====================================");
for(Map.Entry<String, String> entry : map.entrySet()){
System.out.println("键 key :"+entry.getKey()+" 值value :"+entry.getValue());
}
System.out.println("====================================");
Iterator<Map.Entry<String, String>> it=map.entrySet().iterator();
while(it.hasNext()){
Map.Entry<String, String> entry=it.next();
System.out.println("键key :"+entry.getKey()+" value :"+entry.getValue());
}
System.out.println("====================================");
}
map.forEach((k, v) -> System.out.println("key = " + k + ", value = " + v));
}