java Map的遍历
来源:互联网 发布:php数组按id排序 编辑:程序博客网 时间:2024/06/05 22:34
1、利用值进行遍历
2、利用键进行遍历
3、利用Entry进行遍历
Map<K, V> map = new HashMap<K, V>();Collection<V> values = map.values();for (Iterator<V> iterator = values.iterator(); iterator.hasNext();) {V value = iterator.next();System.out.println(value);}
2、利用键进行遍历
Map<K, V> map = new HashMap<K, V>();Set<K> keySet = map.keySet();for (Iterator<K> iterator = keySet.iterator(); iterator.hasNext();) {K key = iterator.next();V value = map.get(key);System.out.println(value);}
3、利用Entry进行遍历
Map<K, V> map = new HashMap<K, V>();Set<Map.Entry<K, V>> entrySet = map.entrySet();for (Iterator<Map.Entry<K, V>> iterator = entrySet.iterator(); iterator.hasNext();) {Map.Entry<K, V> entry = iterator.next();System.out.println(entry.getKey() + "=" + entry.getValue());}
- 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的方法
- IE6中PNG透明背景图片处理方法
- ios知识整理
- 当你对未来迷茫的时候请看看
- 程序员应该多问些为什么
- 【原创】Java与数据结构(中篇:树)
- java Map的遍历
- 一个有趣的问题:关于Java中的Integer
- HDU H204 阿牛的EOF牛肉串
- html标签默认样式
- C++读写文件并排序
- spring3.2 mvc web.xml
- 16-循环控制
- linux 下串口命令
- javaScript用正则验证QQ