fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13.  
  14. String s = "abdsd3$asda$asasdd$sadas";
  15. int[] counts = new int[128];
  16. for (int i = 0; i < s.length(); i++) {
  17. char ch = s.charAt(i);
  18. if (ch < 128) {
  19. counts[ch]++;
  20. } else {
  21. System.err.println("Character is out of range: "+ch);
  22. }
  23. }
  24. for (char c = 0 ; c < 128 ; c++) {
  25. if (counts[c] != 0) {
  26. System.out.println(c + " : " + counts[c]);
  27. }
  28. }
  29. }
  30. }
Success #stdin #stdout 0.07s 381184KB
stdin
Standard input is empty
stdout
$ : 3
3 : 1
a : 7
b : 1
d : 6
s : 6