将字符串中进行反转。abcde --> edcba
**@author Administrator
*/
public class Test8 {
public static void main(String[] args)
{
String str = "abcde";//要转换的字符串
int len = str.length();//字符串长度
String st[] = new String[len];
//开始转换
for(int i = 0; i < len; i++)
st[i] = str.charAt(i) + "";
StringBuffer sb = new StringBuffer();
for(int k = len-1; k >=0; k--){
sb. append(st[k]);
}
str = sb.toString();
System.out.println(str);
}
}
|
|