Kursusindhold
Java Extended
Java Extended
Challenge: Uppercase Even Words
Opgave
Swipe to start coding
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.
Løsning
solution
Var alt klart?
Tak for dine kommentarer!
Sektion 3. Kapitel 3
Challenge: Uppercase Even Words
Opgave
Swipe to start coding
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.
Løsning
solution
Var alt klart?
Tak for dine kommentarer!
Sektion 3. Kapitel 3