在原来字符串上进行翻转
public class str31 {
public static void main(String[] args)
{
str31 str = new str31();
String a ="this is a dog";
StringBuilder sb = new StringBuilder(a);
char temp;
int i=0;
int j =sb.length()-1;
while(i<j)
{
temp = sb.charAt(j);
sb.setCharAt(j, sb.charAt(i));
sb.setCharAt(i,temp);
i++;
j--;
}
System.out.println(sb);
}
}