Finding all plurals in an array of Strings I'm looking for feedback on this here code. Is readability an issue? Is it good to mess with all these data types in Java (e.g. strings and Chars and using .equals() and != to compare data from different data types), or is there an easier way to do it? And in general, how can I improve this code?




  Write a method named allPlural that accepts an array of strings as a
  parameter and returns true only if every string in the array is a
  plural word, and false otherwise. For this problem a plural word is
  defined as any string that ends with the letter S, case-insensitively.
  The empty string "" is not considered a plural word, but the
  single-letter string "s" or "S" is. Your method should return true if
  passed an empty array (one with 0 elements).


   public static boolean allPlural(String[] words){
        for (String s : words) {
            // blank string is not plural
            if (s.equals("")) {
                return false;
            }
            // if the strings in the array don't have an s on the end, return false
            if (Character.toUpperCase(s.charAt(s.length()-1)) != 'S') {
                return false;
            }
        }
        return true;
    }
The code is well readable as it is. As long as it solves the problem (it does), it is fine.

For a real-world plural detection, I would add to the class:


  public static boolean isPlural(String s)


to detect if a single word is a proper plural, because it is more complicated than 'ends with "S"'.