// hello world xiao hong >>> hong xiao world hello
public static String conversionStr(String string)
{
if (string == null || "".equals(string))
return null;
String[] arrStr = string.split(" ");
StringBuilder sb = new StringBuilder(string.length());
for (int i=arrStr.length-1;i>=0;i--)
{
sb.append(arrStr[i]).append(" ");
}
return sb.toString();
}
字符串倒序单词顺序不变保留空格
最新推荐文章于 2022-12-01 18:47:09 发布