Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Example 1:
Input: "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc"注意:用StringBuffer 简单的很
public String reverseWords(String s) {
if (s.equals(""))
return "";
String[] sta = s.split(" ");
String re = "";
for (int i = 0; i < sta.length; i++) {
StringBuffer sbf = new StringBuffer(sta[i]);
sbf.reverse();
sta[i] = sbf.toString();
re = re + " " + sta[i];
}
re = re.substring(1, re.length());
return re;
}