记录刷题过程中学到的知识点
containsKey
的使用,判断Map
集合中是否存在指定的键名。
//
Map<String,Integer> map = new HashMap<>();
map.put("name",1);
map.put("age", 2);
if(map.containsKey("name")) {
return map.get("name");
}else {
return false;
}
// return 1
记录刷题过程中学到的知识点
containsKey
的使用,判断Map
集合中是否存在指定的键名。
//
Map<String,Integer> map = new HashMap<>();
map.put("name",1);
map.put("age", 2);
if(map.containsKey("name")) {
return map.get("name");
}else {
return false;
}
// return 1