// bad solution public void addEntryIfKeyDoesNotExist(String key, Integer value) { if (!map.containsKey(key)) { map.put(key, value); } }