StrUtil { public static String reverseInPlace(String s ) { int length = s.length(), last = length - 1; char[] chars = s.toCharArray(); for (int i = 0; i < length/2; i++ ) { char c = chars[i]; chars[i] = chars[last - i]; chars[last - i] = c; } return new String(chars); }  static String reverseInPlace(String s ); static String reverseNew(String s);  }
@Test public void testReverseInPlace() { assertEquals("", StrUtil.reverseInPlace("")); assertEquals("olleh", StrUtil.reverseInPlace("hello")); assertEquals("nellaf", StrUtil.reverseInPlace("fallen")); }