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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/01/65b7ba32f0cfc_57065b7ba32c4fd3.jpg)
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
Get step-by-step solutions from verified subject matter experts
