Write RecursiveStrings with five recursive methods — no loops anywhere:
reverse(String s);count(String s, char c)— how many timescoccurs;countCapitals(String s);removeSpaces(String s);length(String s)— without callings.length().
Each one follows the same pattern: the empty string is the base case; otherwise deal with the first character and call the method on s.substring(1).
main reads a line of text, then a line whose first character is the letter to count. For the input
Wenzhou Kean University
n
the program prints
Reversed: ytisrevinU naeK uohzneW
Occurrences of 'n': 3
Capital letters: 3
Without spaces: WenzhouKeanUniversity
Length, counted recursively: 23