这里将告诉您List containsKey 和Map contains 判断集合中是否包含某个值,教程操作步骤:map集合
//1.第一种
HashMap map = new HashMap();
map.put("1", "value1");
map.put("2", "value2");
Iterator keys = map.keySet().iterator();
while(keys.hasNext()){
String key = (String)keys.next();
if("2".equals(key)){
System.out.println("存在key");
}
}
//2.第二种
boolean flag=map.containsKey("email")
List集合
List list=new ArrayList();
list.add("224");
list.add("2252");
list.add("226");
list.add("227");
if(list.contains("2252")){
System.out.print("包含");
}
List containsKey 和Map contains 判断集合中是否包含某个值就为您介绍到这里,感谢您关注懒咪学编程c.lanmit.com.
本文地址:https://c.lanmit.com/bianchengkaifa/Java/1856.html