大家好,又见面了,我是你们的朋友全栈君。
作用是判断Map中是否有所需要的键值,下面是具体的代码:
public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
map.put("sf2", "111111");
map.put("s3f", "111111");
map.put("s4f", "111111");
map.put("s5f", "111111");
Boolean is = map.containsKey("f2");
if(is){
System.out.println("是有这个值的");
}else{
System.out.println("没有的");
}
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/155726.html原文链接:https://javaforall.cn