HashMap集合的遍历方式
-
先创建回合并赋值
// 创建map集合 赋值 Map<String,Integer> map = new HashMap<>(); for (int i = 0; i < 10; i++) { map.put(i + 1 + "", i); }
-
集合中一些少有人知的方法
// 获取集合长度 map.size(); // 判断集合是否为空 true为空 map.isEmpty(); // hashCode值 "1".hashCode(); // 是否包含key map.containsKey("1"); // 是否包含value map.containsValue("1"); // 传输的值类型为map集合 可以用来合并集合 map