首页 > 其他 > 详细

字符串倒序处理

时间:2021-07-09 16:43:08      阅读:25      评论:0      收藏:0      [点我收藏+]

##字符串处理

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!