Map接口

public class updateStu {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Map<String, String>map = new HashMap<>();
        map.put("01","李同学");
        map.put("02", "魏同学");
        Set<String>set= map.keySet();
        Iterator<String> it = set.iterator();
        System.out.println("Key集合中的元素");
        
        while(it.hasNext()){
            System.out.println(it.next());
        }
        
        Collection<String>coll = map.values();
        it = coll.iterator();
        System.out.println("values集合中的元素");
        while(it.hasNext()){
            System.out.println(it.next());
        }
    }

}

 

posted @ 2019-03-25 12:06  小小超plus  阅读(94)  评论(0编辑  收藏  举报