java - Effective way of replacing containsKey check with methods
https://stackoverflow.com/questions/62879286/effective-way-of-replacing-containskey-check-with-methods-introduced-in-java8-fo
WEBJul 13, 2020 · 2 Answers. Sorted by: 1. You could simplify it using Map.merge on the Map instead of the complete if..else block such as: letterCountMap.merge(letter, 1, Integer::sum); The overall solution could be simplified to: Map<Character, Integer> letterCountMap = new HashMap<>(); for (char letter : str.toCharArray()) {
DA: 43 PA: 56 MOZ Rank: 49