首页 > 其他 > 详细

字符串反写(学习)

时间:2017-03-09 18:36:19      阅读:264      评论:0      收藏:0      [点我收藏+]

今天想起了之前的一个问题,反写字符串的方法。

 

public class shouxie {
public static void main(String[] args) {
String str = "abcdefghijklmnopqrstuvwxyz";
int length = str.length();
char[] chars = str.toCharArray();
for(int i = 0 ; i < length / 2 ; i ++){
char temp;
temp = chars[i];
chars[i] = chars[length - 1 -i];
chars[length -1 - i] = temp;
}
System.out.println(chars);
}
}

这样就可以了。

字符串反写(学习)

原文:http://www.cnblogs.com/April-Chou-HelloWorld/p/6526953.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!