码迷,mamicode.com
首页 > 其他好文 > 详细

用递归机制逆序输出一个字符串

时间:2017-03-25 19:12:32      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:bcd   void   递归   输出   substring   turn   system   str   code   

 1 package fa.ct;
 2 
 3 public class Nixu {
 4 
 5     static String input="abcdefg";
 6     public static  String ltof(String input){
 7         if(input.isEmpty()){
 8             return input;
 9         }
10         return ltof (input.substring (1)) + input.charAt (0);
11     }
12     public static void main(String[] args) {
13         System.out.println(input);
14         System.out.println(ltof(input));
15     }
16 
17 }

 

用递归机制逆序输出一个字符串

标签:bcd   void   递归   输出   substring   turn   system   str   code   

原文地址:http://www.cnblogs.com/zuoting-haoxue/p/6617943.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!