frekuensi angka di java menggunakan hashmap menggunakan getordefault
Map<Character,Integer> frequencies = new HashMap<>();
for (char ch : input.toCharArray())
frequencies.put(ch, frequencies.getOrDefault(ch, 0) + 1);
Powerful Partridge