使用递归算法反转字符串
public class T { //反转字符串 public static String reverseString(String s){ if(s.isEmpty()) return s; return reverseString(s.substring(1))+s.charAt(0); } public static void main(String[] args) { System.out.println(reverseString("123456789")); } }