public static String reverseStr(String s){ int len = s.length(); StringBuffer sb = new StringBuffer(s); for(int i = 0; i < len/2; i++){ int rInx = len - 1 - i; char c = sb.charAt(i); sb.setCharAt(i, sb.charAt(rInx)); sb.setCharAt(rInx, c); } return sb.toString(); } fl("Reverse String 0"); String s = "abc"; String rs = reverseStr(s); System.out.println(rs); // => cba