in java, a HashMap has an antry in which the value is null, question is how to find the key that
is corresponding to the null value?The solution must be efficient
in java, a HashMap has an antry in which the value is null, question is how to find the key that
is corresponding to the null value?The solution must be efficient
please use the method to find the key in HashMap
public boolean containsKey(Object key)
import java.util.HashMap; import java.util.Iterator; import java.util.Set;
public class Test {
public static void main(String[] args) { HashMap map = new HashMap(); Set set = map.keySet(); Iterator it = set.iterator(); while(it.hasNext()){ Object obj = it.next(); if(map.get(obj)==null){ System.out.println(obj); } } } }