I have trying to use hashmap. I have defined hashmap to take key as integer and value as string.
package hello;
import java.util.HashMap;
public class Recursion {
    
    public static void main(String[] args) {
        HashMap<Integer,String> hash1 = new HashMap<Integer,String>();
        hash1.get(5);                  // return null
        hash1.get("hello");            // return null
     
    }
}
In the above code, hash1.get(5) returns null which is expected. But hash1.get("hello") also returns null and doesn't give any exception even though I am trying to get string key. Any idea on the reason?? I tried to see the implementation of get function. I didn't see any type checking there. So, can I assume that there is no type checking even if I defined the type in the generic.
Can someone please explain this in detail and the reasons for why its not giving any compile-time error.