public static void main(String[] args) {
// demo01();
Map<String, Integer> map = new HashMap<>();
map.put("第一個", 1);
map.put("第二個", 2);
map.put("第三個", 3);
map.put("第四個", 4);
if (map.containsKey("第二個")) {//判斷map集合中是否存在指定的key
System.out.println("找到了對應的key值");
} else {
System.out.println("搜索的key值不存在");
}
if (map.containsValue(1)) {//判斷map集合中是否存在指定的Value
System.out.println("找到了對應的value值" + map.get("第二個"));
} else {
System.out.println("搜索的value值不存在");
}
}