java中map的遍历方法
来源:互联网 发布:网络教育专升本条件 编辑:程序博客网 时间:2024/04/29 06:32
今天重新看了一下java基础,总结了一下map的遍历方法,与大家分享。
Map<String,String> map = new HashMap<String, String>();map.put("1", "a");map.put("2", "b");map.put("3", "c");map.put("4", "d");//map遍历方法一Set<String> set1 = map.keySet();Iterator<String> it1 = set1.iterator();while(it1.hasNext()){String key1 = (String) it1.next();String value1 = map.get(key1);System.out.println(key1+"==="+value1);}//map遍历方法二Set<?> set2 = map.entrySet();Iterator<?> it2 = set2.iterator();while(it2.hasNext()){Map.Entry<String, String> entry = (Entry<String, String>) it2.next();String key2 = (String) entry.getKey();String value2 = entry.getValue();System.out.println(key2+"==="+value2);}//map的遍历方法三 jdk5+ 此方法原理依托于方法一for(String set3:map.keySet()){String value3 = map.get(set3);System.out.println(set3+"==="+value3);}//map遍历方法师,jdk5+,此方法原理依托于方法二for(Entry entry:map.entrySet()){String key4 = (String) entry.getKey();String value4 = (String) entry.getValue();System.out.println(key4+"==="+value4);}
0 0
- Java中Map的遍历方法
- Java中Map的遍历方法
- java中map的遍历方法
- Java中Map的遍历方法
- java中map的遍历方法
- Java中遍历一个Map的方法
- java中遍历Map的方法
- Java中遍历Map的方法
- Java中Map的遍历方法
- Java中遍历Map对象的方法
- Java中Map容器的遍历方法
- Java中Map的遍历方法
- java中遍历MAP方法
- java中 Map 遍历方法
- java遍历map的方法
- java遍历map的方法
- Java 遍历Map的方法
- Java Map 遍历的方法
- TortoiseSVN 在Eclipse中冲突解决
- sort list
- 清除页面默认css样式
- Java设计模式——工厂方法模式(factory method)
- OSI网络七层协议以及每层的作用
- java中map的遍历方法
- 程序员修炼之路-(2)线性表(下):栈、队列
- WMS仓库管理系统---(18)盘点管理初盘单移动盘点
- 网络请求链接为JSon格式时的处理办法
- 面试之-集合
- Windows应用程序运行机制(笔记)
- linux安装mysql和使用c语言操作数据库的方法 c语言连接mysql
- WMS仓库管理系统---(19)盘点管理复盘单创建
- Git 常用命令