0

A method to return the frequencies of repeated characters

  • The answer is always the number of all characters in text, not repeated characters! Can I know how to edit it?

    public static int freq(String in ) {
    
      int frequency = 0;
      char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();
      for (int j = 0; j < 25; j++) {
    
        for (int i = 0; i < in .length(); i++) {
          if (alphabet[j] == in .charAt(i)) {
            ++frequency;
          }
        }
      }
    
      return frequency;
    
    }
    
Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252
Y.esk
  • 11
  • 3

0 Answers0