把一个英语句子中的单词次序颠倒后输出。例如输入“how are you”,输出“you are how”...

public class test {

public static void main(String[] args) {
// TODO Auto-generated method stub

String str = "how are you";
String strs[] = str.split(" ");
StringBuffer restr = new StringBuffer();
for(int i = strs.length-1; i >= 0; i--){
System.out.println(strs[i]);
restr.append(" "+strs[i]);
}
System.out.println("反:"+restr);
}

}

转载于:https://www.cnblogs.com/cysking/p/5319405.html

你可能感兴趣的:(把一个英语句子中的单词次序颠倒后输出。例如输入“how are you”,输出“you are how”...)