方法如下:
public static void main(String[] args) {
//新建Map然后填入数据
Map<String, String> map = new HashMap<>();
map.put("key_one", "one");
map.put("key_two", "two");
map.put("key_three", "three");
map.put("key_four", "four");
map.put("key_five", "five");
//通过Map.Entry<>进行遍历
for (Map.Entry<String, String> entry:map.entrySet()) {
System.out.println(entry.getKey()); //获取到map 键
System.out.println(entry.getValue()); //获取到map 值
}
}
最后
以上就是冷艳大象最近收集整理的关于如何遍历Map数组的全部内容,更多相关如何遍历Map数组内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复