字符串反转

public static String reverse(String str){  
        return new StringBuilder(str).reverse().toString();  
    }

public void test09() {  
        String str = "hello";  
  
        for (int i = str.length() - 1; i >= 0; i--) {  
              
            char c = str.charAt(i);  
              
            System.out.print(c);  
        }  
    } 

你可能感兴趣的:(字符串反转)