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. String s1="dghfjghjkjhikjl";
  14.  
  15. char arr[]=s1.toCharArray();
  16.  
  17. for(int i=0;i<s1.length();i++)
  18. {
  19. int count=0;
  20. for(int j=i;j<s1.length();j++)
  21. {
  22.  
  23. if((arr[i]==arr[j])&&(i!=j))
  24.  
  25. {
  26. count++;
  27. System.out.println("the number occurences "+arr[i]+"="+count);
  28.  
  29. }
  30.  
  31.  
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46. }
  47. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
the number occurences       g=1
the number occurences       h=1
the number occurences       h=2
the number occurences       j=1
the number occurences       j=2
the number occurences       j=3
the number occurences       h=1
the number occurences       j=1
the number occurences       j=2
the number occurences       k=1
the number occurences       j=1