字符串反转

public class BaseStudy {

    public static void main(String[] args) {

        String  a = "abcdef";
        //reverse 函数处理
        //StringBuffer sb = new StringBuffer(a);
        //System.out.println(sb.reverse().toString());
        
        //
        int l = a.length();
        String tmp = "";
        //System.out.println("---" +l);
        try{
            for (int i = l-1 ;i >= 0 ;i--){
                tmp = tmp + a.charAt(i);
                System.out.println("---");
            }
            System.out.println("1111111=== "+ tmp );    
        }catch(Exception e){
            e.printStackTrace();
        }
    }

}

 

posted @ 2017-07-11 17:19  YaoYiYao  阅读(128)  评论(0编辑  收藏  举报