Hi,
I'm now working on a program that counts all the uppercase letters in a
string entered in the command line arguement. When I try to compile I get an error with the first line below. I'm not too sure what the problem is. Can anyone help?
// Invoke the countLetters method to count each letter
int[] count = countLetters(word.isUpperCase());
// Display results
for (int i = 0; i < count.length; i++) {
if (count[i] != 0)
System.out.print((char)('a' + i) + " appears " +
count[i] + ((count[i] == 1) ? " time\n" : " times\n"));
}
// Count each letter in the string
public static int[] countLetters(String
word) {
int[] count = new int[26];
for (int i = 0; i < word.length(); i++) {
if (Character.isLetter(word.charAt(i)))
count[(int)(word.charAt(i) - 'a')]++;
}
return count;
Thanks
Stacey
};
}