//遍历key
        for (String key : dic.keySet()
                ) {
            System.out.println(key + dic.get(key));
        }
        //遍历values
        for (String value : dic.values()
                ) {
            System.out.println(value);
        }
        //使用entry遍历键值对
        for (Map.Entry<String,String> entry:dic.entrySet()
             ) {
            System.out.println(entry.getKey()+":"+entry.getValue());
        }

        //用迭代器遍历
        Iterator<Map.Entry<String,String>> itor = dic.entrySet().iterator();
        while (itor.hasNext())
        {
            Map.Entry<String,String> entry =  itor.next();
            System.out.println(entry.getKey()+""+entry.getValue());
        }    

  

相关文章:

  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
  • 2022-01-06
  • 2021-06-30
  • 2022-12-23
  • 2021-11-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
相关资源
相似解决方案