From java docs of Map
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
But following code is throwing Null Pointer exception
.
public class Main {
public static void main(String args[]) throws Exception {
boolean bool = false;
Map<String, Boolean> map = new HashMap<>();
boolean r = bool ? false : map.get("a");
}
}
Can some one help me understand this behavior.