With regard to String handling in Java. The Funworks Java textbook, Learning Unit 1 (Characters and Strings) has exercise 3.3 on page 19.

In this exercise you are required to write Java String handling code that will . . .

  1. Ask the user for a word, phrase or sentence.
  2. Find the first and last characters of the String.
  3. Print the String backwards.
  4. Sequentially harvest letters from the front and the end of the String until there are no more letters left.
  5. Find the middle character or two characters of the String if it has an even number of characters.
  6. Print out only the vowels in a String.
  7. Count the number of spaces in a String.

To do this one needs the following String handling methods – length, charAt, substring, indexOf, contains which are used used with conditional statements and for loops.

Click here for the solution.