//这是一个极为简单的字符串倒序排列.还是那句话,看到字符串,想他的亲兄弟数组.
//将字符串转成数组,对元素进行倒序遍历,然后存入StringBuilder,再打印.
public class Demo08 {
public static void main(String[] args) {
String s = "abcdefg";
StringBuilder sb = new StringBuilder();
char[] ch = s.toCharArray();
for(int x = ch.length -1 ; x >= 0; x --)
{
sb.append(ch[x]);
}
System.out.println(sb.toString());
}
}
|
|