publicclassMyTest{publicstaticvoidmain(String[] args){String s ="abbdfaadqwedqfdad";String s2 ="";for(int i = s.length()-1; i >=0; i--){
s2 += s.charAt(i);}System.out.println(s2);}}}
法三(StringBuilder的reverse()方法):
publicstaticvoidmain(String[] args){String s ="abbdfaadqwedqfdad";StringBuilder stringBuilder =newStringBuilder(s);
stringBuilder.reverse();String s1 = stringBuilder.toString();System.out.println(s1);}
public class MyTest { public static void main(String[] args) { String s="abbdfaadqwedqfdad"; //字符串转化为字符数组 char[] charArray = s.toCharArray(); char[] chars = new char[s.length()]; for (int i = 0; i < charArr