HashMap<Integer, String> hashMap = new HashMap<>();
hashMap.put(1, "aaa");
hashMap.put(2, "baa");
hashMap.put(3, "caa");
System.out.println(hashMap.get(false));
Above code compiles and runs fine.. gives output as null
.
What I am trying to understand is there any autoboxing happening in-between that i seem to miss. Because if generics are applied at compile time, get method shall not allow us to pass a boolean there.
Thanks