(String inp)
| 6 | countDuplicates(s); |
| 7 | } |
| 8 | public static void countDuplicates(String inp) |
| 9 | { |
| 10 | HashMap<Character,Integer> map = new HashMap<>(); |
| 11 | for(int i=0;i<inp.length();i++) |
| 12 | { |
| 13 | map.put(inp.charAt(i),map.getOrDefault(inp.charAt(i),0)+1); |
| 14 | } |
| 15 | for(Map.Entry<Character,Integer> e : map.entrySet()) |
| 16 | { |
| 17 | System.out.println(e.getKey() + ":" + e.getValue()); |
| 18 | } |
| 19 | } |
| 20 | } |