写一个方法,实现字符串的反转
publicclassTest {publicstaticvoidmain(String[] args) {String result=reverse("abc");System.out.println(result);}publicstaticString reverse(String str){StringBuilder result=newStringBuilder("");char[] chArra=str.toCharArray();for(inti=chArra.length-1;i>=0;i--){charch=chArra[i];result.append(ch);
}returnresult.toString();}}
本文来自博客园,作者:与乐i,转载请注明原文链接:https://www.cnblogs.com/linanana/p/14650388.html