Increment an Integer within a HashMap September 15, 2023 by Tarik This is the shortest code that does this job. myMap.put(key, myMap.get(key) + 1) I think it is not too long.