I have this String to String map, and I am trying to pass char as a key
Map<String, String> phone = new HashMap<String, String>() {{
put("2", "abc");
put("3", "def");
put("4", "ghi");
put("5", "jkl");
put("6", "mno");
put("7", "pqrs");
put("8", "tuv");
put("9", "wxyz");
}};
String letterList = phone.get('2'); //null
String letterList = phone.get(String.valueOf('2')); //it works
Why does the first case not work? In my understanding, char can be implicitly converted to String "2", and HashMap use equals() to compare keys, so that it should retrieve the key in map?