package demo1;
public class MyClass1
{
public static String Reserver(String str){
String [] myStr=str.split(" ");
StringBuffer newStr=new StringBuffer();
for(int i=myStr.length-1;i>=0;i--){
newStr.append(myStr[i]+" ");
}
return newStr.toString();
}
public static void main(String []args){
String str="I am a Chinese Hello Word!";
System.out.println(Reserver(str));
}
}
输出:Word! Hello Chinese a am I