Question: public static String reverseEachWord (String oldString, String[] commandWords) // TODO: Reverse each individual word in oldString using the reverseString function which you filled in

public static String reverseEachWord (String oldString, String[] commandWords) // TODO: Reverse each

public static String reverseEachWord (String oldString, String[] commandWords) // TODO: Reverse each individual word in oldString using the reverseString function which you filled in // 1. Call split (" ") on oldString (split up the string on space), and store the result in a String array // 2. Create a new empty string called result (i.e., String result = "") // 3. Create a for loop and iterate over each element of the String array from step 1 // 4. Within the loop, if the index is greater than 0, add a blank space to result (i.e., result += "") // 5. Within the loop, add the reversed version of the array String to result (i.e., result += reverseString (array[i])) // 6. Return result // Note: It was a design choice to not error out if arguments were erroneously included.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!