iterator 遍历map




public static void main(String[] args) throws IOException {

    Map map = new HashMap();
    map.put("1", "value1");
    map.put("2", "value2");
    map.put("3", "value3");

将map转成entryset

通过while循环获取 key与value值

  Iterator> iterator = map.entrySet().iterator();
        while(iterator.hasNext()){
         Entry next = iterator.next();
         System.out.println(next.getKey()+next.getValue());
         
        }

}

你可能感兴趣的:(iterator 遍历map)