public class StringReverse {
public static void Reverse(){
String s=“qwertyuiop”;
System.out.println(s);
char[] str=s.toCharArray();//转换成数组
int n=str.length-1;//最大下标
int halflength=n/2;//次数
for(int i=0;i<=halflength;i++){
char temp=str[i];
str[i]=str[n-i];
str[n-i]=temp;
}
System.out.println(str);
}
public static void main(String[] args){
StringReverse.Reverse();
}
}