fork(1) 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. public static void main (String[] args) throws java.lang.Exception {
  10.  
  11. String s = "Program";
  12. int[] c = new int[256]; // Array for ASCII characters
  13.  
  14. // Increment count for each character
  15. for (int i = 0; i < s.length(); ++i) {
  16. c[i]++;
  17. }
  18.  
  19. System.out.println("Character Occurrences:");
  20.  
  21. // Print characters with non-zero counts
  22. for (int i = 0; i < c.length; i++) {
  23. if (c[i] > 0) {
  24. System.out.println((char) i + " : " + c[i]);
  25. }
  26. }
  27. }
  28. }
Success #stdin #stdout 0.19s 57508KB
stdin
Standard input is empty
stdout
Character Occurrences:
 : 1
 : 1
 : 1
 : 1
 : 1
 : 1
 : 1