1. public class StringReverse {
    2. public static void main(String[] args) {
    3. String str = "00nuhsnehc";
    4. System.out.println(reverse(str));
    5. }
    6. public static String reverse(String str) {
    7. if (str == null || str.trim().length() == 0) {
    8. return "";
    9. }
    10. final String c = str.substring(0, 1);
    11. final String substring = str.substring(1);
    12. //递归取出前一个
    13. String temp = reverse(substring);
    14. return temp + c;
    15. }
    16. }