Define a method named countAll that accepts a String as an argument. The method
ID: 673757 • Letter: D
Question
Define a method named countAll that accepts a String as an argument. The method must
return an array of int of size 27, such that the value in position 0 is a count of the number of
‘a’ and ‘A’ characters in the input, the value in position 1 is a count of the number of ‘b’ and
‘B’ characters in the input, … the value in position 25 is a count of the number of ‘z’ and ‘Z’
characters in the input, and the value in position 26 is a count of all the non-alphabetic
characters in the input. For example,
• if s is "", then all entries in the array must be 0.
• if s is "a", then all entries in the array must be 0 except for entry 0, which must be 1.
• if s is "Baaa!", then all entries in the array must be 0 except for:
o entry 0, which must be 3,
o entry 1, which must be 1, and
o entry 26, which must be 1.
The only methods you may call on the String s are charAt(int) and length(). You may use
the static toLowerCase method defined in the Character class, which maps a char to its
lower-case equivalent. For example,
• Character.toLowerCase('a') returns 'a'
• Character.toLowerCase('A') returns 'a'
• Character.toLowerCase('%') returns '%'
You may, if you wish, define private helper method that you call from your character
counting method.