利用双指针来反转 字符数组
public class reveserString {
public static void reveserSting( char[] s){
int i=0,j=s.length-1;
//采用双指针的方式进行修改
char temp;
while(i<j){
temp=s[i];
s[i]=s[j];
s[j]=temp;
i++;
j--;
}
}
public static void main(String[] args) {
char [] s={'a','b','c','d','e'}; //输出结果 [e, d, c, b, a]
reveserSting(s);
System.out.println(Arrays.toString(s));
}