Java 程序在保留空间位置的情况下反转给定的字符串。
您可以使用reverse()StringBuffer类的方法保留空格来反转给定String的内容。
示例
public class Test {
public static void main(String args[]) {
String str = "hi welcome to Nhooo";
String strArray[] = str.split(" ");
StringBuffer sb= new StringBuffer(str);
sb.reverse();
for(int i=0 ; i输出结果tn iopslai ro tuT ot emoclew ih