Conteúdo do Curso
Java Extended
Java Extended
Challenge: Uppercase Even Words
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.
Obrigado pelo seu feedback!
Challenge: Uppercase Even Words
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.
Obrigado pelo seu feedback!