Java - map 遍历方式
来源:互联网 发布:百雀羚淘宝网 编辑:程序博客网 时间:2024/05/16 18:19
package com.execute.demo;import java.util.HashMap;import java.util.Iterator;import java.util.Map;/** * Created with IntelliJ IDEA by zhouk. */public class MapTraversal { public static void main(String[] args) { Map<String, String> map = new HashMap<String, String>(); map.put("Java", "Bruce Eckel"); map.put("Spring", "Craig Walls"); map.put("JavaScript", "Nicholas C.Zakas"); // method 1 for (String key : map.keySet()) { System.out.println("key: " + key + ", value: " + map.get(key)); } // mothod 2 for (String value : map.values()) { System.out.println("value: " + value); } // method 3 Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, String> entry = iterator.next(); System.out.println("key: " + entry.getKey() + ", value: " + entry.getValue()); } // method 4 for (Map.Entry<String, String> entry : map.entrySet()) { System.out.println("key: " + entry.getKey() + ", value: " + entry.getValue()); } }}
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遍历方式的选择1
- Java Map遍历方式的选择
- 【icpc网络赛大连赛区】Sparse Graph
- GridLayout
- leetcode 241. Different Ways to Add Parentheses
- Java接口修饰符详解。
- 某VTE web后台岗 面试经验
- Java - map 遍历方式
- 连续输入数字,以空格为分割,换行为结束,将数字输入到数组中
- mybatis-generator报Exception getting JDBC Driver解决办法
- PAT之继续3n+1猜想(B)
- 如何执行一个java文件
- Factorization Machines 学习笔记(一)预测任务
- 从切比雪夫不等式到大数定理
- hdu 5843 ICPC Football Games
- Factorization Machines 学习笔记(二)模型方程