使用entrySet遍历map
来源:互联网 发布:淘宝店发货地址 编辑:程序博客网 时间:2024/06/15 21:48
package test;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedHashMap;import java.util.Map;import java.util.Map.Entry;public class test3 {public static void main(String[] args) {Map<String, String> map = new HashMap<>();map.put("1","2");map.put("2","3");map.put("3","4");Map<String,String> map1 = Map.of("k1", "v1", "k2", "v2", "k3", "v3");//java9引入的方法,map1集合是不可变集合,且key和value的值都不能为nullMap<String,String> map2 = new LinkedHashMap<>(Map.of("k1", "v1", "k2", "v2", "k3", "v3"));map2.put("1","2");for (Iterator<Entry<String, String>> iter = map2.entrySet().iterator();iter.hasNext();) {Entry<String, String> entry = iter.next();System.out.println("key=" + entry.getKey());System.out.println("value=" + entry.getValue());}System.out.println(map1.getClass());}}
阅读全文
0 0
- 使用entrySet遍历map
- entrySet遍历map
- Map遍历之entrySet()
- 利用Map.EntrySet遍历
- 【Map使用】遍历Map集合案例keySet()和 entrySet()
- Java推荐使用entrySet()来遍历Map集合
- 使用entrySet遍历HashMap
- 使用entrySet遍历HashMap
- Map的遍历:keySet与entrySet
- entrySet用法 以及遍历map的用法
- 遍历 Map 中 EntrySet 集合一点思考。
- entrySet用法 以及遍历map的用法
- entrySet和keySet遍历Map的区别
- 另一种遍历Map的方式: Map.Entry 和 Map.entrySet()
- 另一种遍历Map的方式: Map.Entry 和 Map.entrySet()
- 另一种遍历Map的方式 Map.Entry 和 Map.entrySet()
- 另一种遍历Map的方式: Map.Entry 和 Map.entrySet()
- 另一种遍历Map的方式: Map.Entry 和 Map.entrySet()
- 转载4
- 修改
- Spring Cloud (13) | Router and Filter: Zuul
- 《学习OpenCV》第七章直方图(练习7.2)
- 【算法】归并排序
- 使用entrySet遍历map
- GIS开源软件大全
- 《汇编语言》第一章——基础知识
- 2017 android面试题总结
- NameNode元数据内存加载
- 【Scikit-Learn 中文文档】模型持久化
- 超级实用且不花哨的js代码大全
- 倒排高级算法
- python中的list和array的不同之处