gistfile1.txt public class StringReverse { private String string = "zhangshuai"; @Test public void test(){ System.out.println(reverse1()); System.out.println(reverse2()); System.out.println(reverse3(string)); } /** * 利用数组反转 * @r
public class StringReverse { private String string = "zhangshuai"; @Test public void test(){ System.out.println(reverse1()); System.out.println(reverse2()); System.out.println(reverse3(string)); } /** * 利用数组反转 * @return string */ public String reverse1(){ char[] chars = string.toCharArray(); //不是实际长度而是其-1 int length = chars.length; for(int i=0;i