描述
将一个英文语句以单词为单位逆序排放。例如“I am a boy”,逆序排放后为“boy a am I”
static String solution(String str){
String[] strs = str.split(" ");
String result = "";
for (int i = strs.length - 1; i >= 0; i--){
result = result + strs[i] + " ";
}
return result.toString().trim();
}
网友评论