Making an integer with the constructor Integer() is depreciated.
Try making id like:
int id = 1;
This should return "John", but I'm getting null. What’s wrong with my HashMap logic?
Map<Integer, String> map = new HashMap<>();
map.put(1, "John");
Integer id = new Integer(1);
System.out.println(map.get(id)); // prints null
To reply to a question, please log in.