代码实现为
package com.bird.software;
/**
*
* @author Bird
*
*/
public class Test7 {
public static void main(String [] args){
System.out.println(reverseString("abcdefg"));
}
public static String reverseString(String x){
if(x == null || x.length() < 2) return x;
return reverseString(x.substring(1, x.length()))+ x.charAt(0);
}
}
运行结果为
gfedcba