字符串倒序处理

##字符串处理

str1="hello the world !"

str2="!world the hello"

已知str1,要求倒序处理实现str2

直接上代码

import org.junit.Test;

public class StringManage {
    /* 字符串处理
    hello the world !
    倒序处理为
    !world the hello*/

    public String StringManageFun(String param) {
        String result = "";
        String[] str;
        str = param.split(" ");
        for (int i=str.length-1;i>=0;i--){
            result=result+str[i]+" ";
        }
        return result;
    }

    @Test
    public void fun(){
        String str1="hello the world !";
        String str2=StringManageFun(str1);
        System.out.println(str2);
    }
}
原文地址:https://www.cnblogs.com/KevinFeng/p/14990376.html