JZ44 翻转单词顺序列
翻转单词顺序列
http://www.nowcoder.com/questionTerminal/3194a4f4cf814f63919d0790578d51f3
使用String.split(" ")
import java.util.*; public class Solution { public String ReverseSentence(String str) { if(str==null||str.length()==0||str.trim().length()==0) return str; String[] strs=str.trim().split(" "); StringBuilder b=new StringBuilder(); for(int i=strs.length-1; i>0; i--) b.append(strs[i]+" "); b.append(strs[0]); return b.toString(); } }