当前位置:网站首页>倒序输出字符串
倒序输出字符串
2022-04-22 05:46:00 【Cx_轩】
倒序输出字符串
public static void main(String[] args) {
String str = "!xc doog";
String[] content = str.split(" ");
String result = "";
for (String s : content) {
result +=revertString(s);
}
System.out.println(result);
}
public static String revertString(String str) {
if (str == null) {
return null;
}
char[] chars = str.toCharArray();
int len = chars.length;
int half = len/2;
char first;
for (int i = 0; i < half; i++) {
first = chars[i];
chars[i] = chars[len-1-i];
chars[len-1-i] = first;
}
return new String(chars);
}输出
结果:cx!good
版权声明
本文为[Cx_轩]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_25223941/article/details/50125393
边栏推荐
- Thread content learning
- 数据总线bus实现兄弟组件之间的通信
- Compiling OpenSSL on HP UNIX and using
- Interaction method I between STM32 single chip microcomputer and ld3320 voice module
- AIX6. 1 compile OpenSSL
- c#catch错误信息自定义显示
- Daily learning record -- solving graphviz Chinese garbled code problem
- I/O多路复用(select/poll/epoll)
- 单、多通道图像反差处理
- C learning experience of commission, thread and timer
猜你喜欢

通过js创建单元格(while循环)

在components文件夹下创建Tabbar组件,公用

Modbus Protocol

STM32 study notes 4 - HC_ Commissioning record of SR04 ultrasonic ranging module

关于手眼标定中RT矩阵的欧拉角和Halcon中pose的类型之间的关系

常见面试问题 - 2(计算机网络)

快应用底部导航栏

QT add PRI compile run: error: fatal error: no input files problem solving

jeecgboot-online表单开发-控件配置

TCP通讯MODBUS协议解析
随机推荐
机器人抓取物体原理初步
Pykmip test
jeecgboot-online在线开发2
Preliminary study on the principle of robot grasping objects
算数和逻辑操作
QQueue使用介绍
QSslSocket::connectToHostEncrypted: TLS initialization failed
Rtl8367 learning note 1 - Basics
UTF8转std:string和std:string转UTF8
Dlopen calls dynamic library
AD5724 bipolar ADC
Setting time and date display of QT learning
QSS、QDateEdit、QCalendarWidget自定义设置
写一个函数的声明,使其返回数组的引用并且该数组包含10个string对象(笔记)
vector与arrange的异同(小记)
关于手眼标定中RT矩阵的欧拉角和Halcon中pose的类型之间的关系
快应用模糊搜索
搞懂Promise async await 之间的联系
通过js创建单元格(while循环)
Jeecgboot online form development - control configuration