1
2
3
4
5
6
7
8
9
10
11
12
class Solution {
public String reverseWords(String s) {
String[] words = s.split(" ");
StringBuilder ans = new StringBuilder();
for (String word : words) {
StringBuilder currWord = new StringBuilder(word);
ans.append(currWord.reverse()).append(" ");
}
ans.setLength(ans.length() - 1);
return ans.toString();
}
}

这个没什么可说的.