fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. Map hitcounts = new HashMap();
  9. String uppercase_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  10.  
  11. for (char uppercase_char : uppercase_alphabet.toCharArray())
  12. {
  13. hitcounts.put(uppercase_char, 0);
  14. }
  15.  
  16. String input_string = "Make This WhatEveR input You Want";
  17.  
  18. for (char character : input_string.toCharArray())
  19. {
  20. if (hitcounts.containsKey(character))
  21. {
  22. hitcounts.put(character, (int)hitcounts.get(character) + 1);
  23. }
  24. }
  25.  
  26. System.out.println(hitcounts);
  27. }
  28. }
Success #stdin #stdout 0.06s 215552KB
stdin
Standard input is empty
stdout
{D=0, E=1, F=0, G=0, A=0, B=0, C=0, L=0, M=1, N=0, O=0, H=0, I=0, J=0, K=0, U=0, T=1, W=2, V=0, Q=0, P=0, S=0, R=1, Y=1, X=0, Z=0}