java使用迭代器遍历map

 Map m=new HashMap();
        m.put("1","张三");
        m.put("2","李四");
        m.put("3","王五");
        m.put("4","赵六");
        Iterator> it=m.entrySet().iterator();
        while (it.hasNext()){
            Map.Entry next = it.next();
            System.out.println(next.getKey()+"+++++++"+ next.getValue());

        }

java使用迭代器遍历map_第1张图片

 

你可能感兴趣的:(java,jvm,servlet)