Checking of presence of a dictionary key in Java
Forums:
Map<Integer, String> dic = new HashMap<Integer, String>();
dic.put(1, "one");
dic.put(2, null);
Boolean exists1 = dic.containsKey(1);
//exists1 is true
Boolean exists2 = dic.containsKey(2);
//exists2 is true
Boolean exists3 = dic.containsKey(3);
//exists3 is false
- Log in to post comments