Map集合提供了集合之间一种映射关系,让集合和集合之间产生关系。
1.添加功能
2.删除功能
3.遍历功能
4.获取功能
5.判断功能
6.修改功能
7.长度功能
Set<Key> set = map.keySet()
public class Test {
    public static  void main(String[] args) {
        Map<String,Integer> map = new HashMap<String,Integer>();
        map.put("张三", 18);
        map.put("李四", 19);
        map.put("王五", 18);
        map.put("赵六", 21);
        Set<String> ks = map.keySet();
        for(String s:ks){
            Integer i = map.get(s);
            System.out.println("姓名:"+s+"\t年龄:"+i);
        }
    }
}Set<Map.Entry<Key, Value>> set = map.entrySet();
public class Test {
    public static  void main(String[] args) {
        Map<String,Integer> map = new HashMap<String,Integer>();
        map.put("张三", 18);
        map.put("李四", 19);
        map.put("王五", 18);
        map.put("赵六", 21);
        Set<Entry<String,Integer>> mks = map.entrySet();
        for(Entry<String,Integer> ks :mks){
            String k  = ks.getKey();
            Integer i = ks.getValue();
            System.out.println("姓名:"+k+"\t 年龄:"+i);
        }
    }
}以上
@Fzxey
原文:https://www.cnblogs.com/fzxey/p/10801329.html