我是靠谱客的博主 饱满枕头,这篇文章主要介绍使用entrySet进行map的遍历,现在分享给大家,希望可以做个参考。

示例:使用entrySet进行map的遍历,直接通过getKey()和getValue()获取键值

public static void main(String args[]) {

     Map<String,String> map = new HashMap<String,String>(16);

     map.put("1","张三");

     map.put("2","李四");

     map.put("3","王五");

     Iterator<Map.Entry<String,String>> entryIterator = map.entrySet().iterator();

     while (entryIterator.hasNext()) {

           Map.Entry<String, String> entry = entryIterator.next();

           System.out.println("key="+ entry.getKey() +"value="+ entry.getValue());

      }

}

最后

以上就是饱满枕头最近收集整理的关于使用entrySet进行map的遍历的全部内容,更多相关使用entrySet进行map内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(91)

评论列表共有 0 条评论

立即
投稿
返回
顶部