Course Content
Java Extended
Java Extended
Challenge: Uppercase Even Words
Task
Swipe to show code editor
Your task is to convert each word at an even position to uppercase and return the modified string.
- Split the input string into an array of words.
- Create a
StringBuilder
to build the resulting string. - Loop through each word in the array using its index.
- For each word, check if its index is even.
- If the index is even, convert the word to uppercase and append it to the result string.
- If the index is odd, append the word as is.
- Return the final string after processing all words.
Solution
solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 3
Challenge: Uppercase Even Words
Task
Swipe to show code editor
Your task is to convert each word at an even position to uppercase and return the modified string.
- Split the input string into an array of words.
- Create a
StringBuilder
to build the resulting string. - Loop through each word in the array using its index.
- For each word, check if its index is even.
- If the index is even, convert the word to uppercase and append it to the result string.
- If the index is odd, append the word as is.
- Return the final string after processing all words.
Solution
solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 3
Switch to desktop for real-world practiceContinue from where you are using one of the options below