Map遍历方式
来源:互联网 发布:oracle sql连接字符串 编辑:程序博客网 时间:2024/05/16 15:21
1.for-each迭代entries
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for(Map.Entry<Integer,Integer> entry : map.entrySet()){
system.out.println("ket: " + entry.getKey() + ", value: " + entry.getValue);
}
map为null抛出NullPointException, for-each只支持jdk1.5以上的版本
2.for-each迭代key-value
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for(Integer key : map.keySet()){
System.out.println("key:" + key + ",value:" + map.get(key));
}
3.用Iterator进行迭代
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
Iterator<Map.Entry<Integer,Integer>> entries = map.entrySet().iterator();
while(entries.hasNext()){
Map.Entry<Integer,Integer> entry = entries.next();
System.out.println("Key:" + entry.getKey() + "value:" + entry.getValue())
}
0 0
- map集合遍历方式
- Map多种方式遍历
- Map的遍历方式
- Map的遍历方式
- map遍历方式
- 遍历Map集合方式
- 遍历Map的方式
- Java Map遍历方式
- java Map遍历方式
- map的遍历方式
- Java map 遍历方式
- Map集中遍历方式
- Map迭代器两种遍历方式
- Map的遍历方式
- 遍历Map的方式
- Map的遍历方式
- Map的遍历方式
- map遍历的方式
- ubunbut下文字转图片报错, convert : unable to read font
- iOS类型编码Type Encodings与属性类型Property Type
- iOS钥匙串返回-50
- SQL的内连接与外连接
- android 流布局 FlowLayout
- Map遍历方式
- TensorFlow入门教程集合
- iOS积分抽奖Demo,可以人为控制不同奖项的得奖率
- 背包九讲之01背包问题
- mysql计算时间差
- 并查集:poj2524:
- 单机程序修改log4j配置文件位置
- JSON互相转换的工具类
- POJ 1236 Network of Schools(强连通分量缩点+tarjan算法)