思路1:转换成char数组,然后做数组的反转,
class Solution {
public String reverseString(String s) {
char[] ch=s.toCharArray();
for(int i=0;i<ch.length/2;i++){
char temp=ch[i];
ch[i]=ch[ch.length-1-i];
ch[ch.length-1-i]=temp;
}
String result = new String(ch);
return result;
}
}