(String s)
| 1 | public class Solution { |
| 2 | public String reverseWords(String s) { |
| 3 | String words[] = s.split(" "); |
| 4 | StringBuilder ans = new StringBuilder(); |
| 5 | for (String word: words) |
| 6 | ans.append(new StringBuffer(word).reverse().toString() + " "); |
| 7 | return ans.toString().trim(); |
| 8 | } |
| 9 | } |