String input="i love you";
String[] s=input.split(" ");//用空格切割并存入数组
String output="";
for(int i=s.length-1;i>=0;i--){//for遍历
output=output+s[i]+" ";
}
System.out.println(output);
输出:you love i
String input="i love you";
String[] s=input.split(" ");//用空格切割并存入数组
String output="";
for(int i=s.length-1;i>=0;i--){//for遍历
output=output+s[i]+" ";
}
System.out.println(output);
输出:you love i