逆向输出传入字符串

定义一个可以逆向输出传入字符串的方法;例如:传入”hello”,输出”olleh”

public static String reverseString(String s) {
        
        String result = "";
        //这里使用java的split方法肩膀给传入的字符串按照每一个字符保存为数组
        String[] test = s.split("");
        //逆向将数组内容相加
        for(int i=test.length-1;i>=0;i--) {
            result = result + test[i];
        }
        return result;        
    }
原文地址:https://www.cnblogs.com/JianXu/p/5703918.html