Java Program to reverse each word in StringWe can reverse each word of a string by the help of reverse(), split() and substring() methods. By using reverse() method of StringBuilder class, we can reverse given string. By the help of split("\\s") method, we can get all words in an array. To get the first character, we can use substring() or charAt() method. Let's see the example to reverse each word in a string. File: StringFormatter.java File: TestStringFormatter.java Output: ym eman si nahk I ma oonos lawsiaj
Next TopicJava String FAQs
|