Junior — Senior
Reverse the order of characters in each word while maintaining the sequence of words
livecode
Task condition
Given a string input. It is necessary to reverse the order of characters within each individual word, while keeping the order of the words in the sentence unchanged. How to accomplish this?
import java.io.*;
class MyCode {
public static void main(String[] args) {
String input = "Name is the best IT company!";
System.out.println(reverseWordChars(input));
System.out.println("!/ynapmoc TI tseb eht si emaN".equals(reverseWordChars(input)));
}
public static String reverseWordChars(String str) {
return new StringBuilder(str).reverse().toString();
}
}