字符串如何转变为倒叙
2016-04-05 17:46
417 查看
要求:把"a67b"进行倒叙;
分析:1.把字符串转换成 Char 类型的数组;
2.利用循环把它们转换位置;
public class Demo3 {
public static void main(String[] args) {
(1.把字符串转换成 Char 类型的数组;)
String a= "a67b";
char[] temp=a.toCharArray( );
(2.利用循环把它们转换位置;)
for (int x =0; x < temp.length / 2; x++){
char a1 = temp[x];
temp[x] = temp[temp.length - 1 - x];
temp [temp.length -1 - x] = a1;
}
System.out.println( String.valueOf(temp));
}
}
分析:1.把字符串转换成 Char 类型的数组;
2.利用循环把它们转换位置;
public class Demo3 {
public static void main(String[] args) {
(1.把字符串转换成 Char 类型的数组;)
String a= "a67b";
char[] temp=a.toCharArray( );
(2.利用循环把它们转换位置;)
for (int x =0; x < temp.length / 2; x++){
char a1 = temp[x];
temp[x] = temp[temp.length - 1 - x];
temp [temp.length -1 - x] = a1;
}
System.out.println( String.valueOf(temp));
}
}
相关文章推荐
- Android百度地图开发 百度地图得到当前位置
- Ehcache解读
- 自制反汇编逆向分析工具 迭代第四版本
- VS 常用高效 快捷键
- 济南android培训机构应该如何来选择?
- MVC API
- unity, 使导入的材质名与3dmax中一致
- JVM监控与调优
- vim搜索
- 【Linux】Sed简明教程
- linux backtrace追踪错误调用
- 高斯模糊的算法
- How to use AIDL
- Android开发常用工具方法
- Android中Binder的学习
- Sublime Text 输入中文显示方框问号乱码
- Java 集合体系之 Map 源码分析
- Material Design UI Widgets —— Palette 调色板
- 关于RMAN-06207和RMAN-06208错误的分析以及解决办法
- Linux 常用操作