当前位置:网站首页>Output string in reverse order
Output string in reverse order
2022-04-23 05:20:00 【Cx_ Xuan】
Output string in reverse order
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);
}
Output
result :cx!good
版权声明
本文为[Cx_ Xuan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220545385626.html
边栏推荐
- Good simple recursive problem, string recursive training
- 项目经理值得一试的思维方式:项目成功方程式
- Cloud computing and cloud native architecture design of openshift
- egg测试的知识大全--mock、superTest、coffee
- Solution of how to log in with mobile phone verification code in wireless network
- When is it appropriate for automated testing? (bottom)
- MFC实现资源单独Dll实现
- The source of anxiety of graduating college students looking for technology development jobs
- 低代码和无代码的注意事项
- [untitled] kimpei kdboxpro's cool running lantern coexists with beauty and strength
猜你喜欢
2021-10-12
The 2021 IT industry project management survey report was released!
My old programmer's perception of the dangers and opportunities of the times?
Graphics. Fromimage reports an error "graphics object cannot be created from an image that has an indexed pixel..."
引入精益管理方式,需要提前做到这九点
Graphics.FromImage报错“Graphics object cannot be created from an image that has an indexed pixel ...”
Domain driven model DDD (III) -- using saga to manage transactions
Blender programmed terrain production
Redis persistence
Using PHP post temporary file mechanism to upload arbitrary files
随机推荐
Modèle axé sur le domaine DDD (III) - gestion des transactions à l'aide de Saga
Traversal of tree
Golang select priority execution
Routing parameters
Unique primary key ID of tidb sub table -- solution to failure of sequence and Gorm to obtain primary key
即将毕业的大学生找技术开发工作的焦虑根源
2021-10-12
Kanban Quick Start Guide
好的测试数据管理,到底要怎么做?
!!!!!!!!!!!!!!!!!!
MySQL foreign key constraint
Data security has become a hidden danger. Let's see how vivo can make "user data" armor again
C test calls the paddlesharp module to recognize pictures and words
开源规则引擎——ice:致力于解决灵活繁复的硬编码问题
Logrus set log format and output function name
工具在数字化转型中扮演了什么样的角色?
My old programmer's perception of the dangers and opportunities of the times?
egg测试的知识大全--mock、superTest、coffee
The source of anxiety of graduating college students looking for technology development jobs
MySQL basics 3