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. char Char;
  13. int count;
  14. String s = "Par programming is fun!";
  15. s = s.toLowerCase();
  16. String carateresSaidos = "";
  17.  
  18. for (Char = 0; Char <= s.length()-1; Char++) {
  19. count = 0;
  20.  
  21. if (carateresSaidos.indexOf(s.charAt(Char))==-1){
  22. for (int i = 0; i < s.length(); i++) {
  23. if (s.charAt(i) == s.charAt(Char)) {
  24. count++;
  25. }
  26. }
  27. if (count > 1){
  28. System.out.println("Number of occurences of " + s.charAt(Char) + " is " + count);
  29. }
  30. carateresSaidos+=s.charAt(Char);
  31. }
  32. }
  33. }
  34. }
Success #stdin #stdout 0.1s 27696KB
stdin
Standard input is empty
stdout
Number of occurences of p is 2
Number of occurences of a is 2
Number of occurences of r is 3
Number of occurences of   is 3
Number of occurences of g is 2
Number of occurences of m is 2
Number of occurences of i is 2
Number of occurences of n is 2