当前位置:网站首页>4. string (reverse order and case conversion)
4. string (reverse order and case conversion)
2022-06-22 16:18:00 【Xiaomurong】
4 character string
Write a program , Realize the conversion of string case and output in reverse order . Requirements are as follows :
(1) Use for Loop the string “HelloWorld” Start traversing from the last character .
(2) If the current character traversed is an uppercase character , Just use toLowerCase() Method to convert it to lowercase characters , Otherwise use toUpperCase() Method to convert it to uppercase characters .
(3) Define a StringBuilder object , call append() Method to add the traversal characters in turn , Last call StringBuider Object's toString() Method , And output the obtained results .
public class Main {
public static void main(String[] args) {
String str = "HellowWorld";
StringBuffer sb = new StringBuffer();
char[] ch = str.toCharArray();
for (int i = str.length() - 1; i >= 0; i--) {
if (ch[i] >= 'a' && ch[i] <= 'z') {
sb.append(String.valueOf(ch[i]).toUpperCase());// Law 1
}
if (ch[i] >= 'A' && ch[i] <= 'Z') {
sb.append(str.toLowerCase().toCharArray()[i]);// Law two
}
}
System.out.print(sb.toString());
}
}
边栏推荐
- 杜老师自建国内不蒜子统计平台
- mysql - sql执行过程
- Ironsource Luna offers a limited time discount for Apple search ads and enjoys 3 months of free service upon registration
- 【山大会议】软件性能优化及bug修复
- odoo系统对原有模型单独开发的视图设置优先级
- pymssql模块使用指南
- Make the text template in pycharm project support jinjia2 syntax
- 数值类型和字符串之间的转换
- 19、 Xv6 context switching (implementation of context switching; encapsulation and recovery of state machine)
- Huawei cloud hcdez special session and Distributed Technology Summit: Huawei cloud distributed cloud native technology and Practice
猜你喜欢

uni开发微信小程序自定义相机自动检测(人像+身份证)

jmeter关联登录302类型的接口

Ironsource Luna offers a limited time discount for Apple search ads and enjoys 3 months of free service upon registration

6.GUI(图形,填充)

SAP ABAP 子屏幕教程:在 SAP 中调用子屏幕-010

Discourse 新用户可插入媒体的数量

信创研究:国产数据库聚焦信创市场,华为Gauss有望成为最强

Gbase "library" special training of innovation and application Committee of Beijing fintech Industry Alliance
![[single chip microcomputer] [make buzzer sound] know the buzzer and let it make the sound you want](/img/cb/826b3591bafa62cc71826732eb32ef.png)
[single chip microcomputer] [make buzzer sound] know the buzzer and let it make the sound you want

#进程地址空间
随机推荐
[Shanda conference] peer connection based on webrtc
Research on ICT: domestic databases focus on the ICT market, and Huawei Gauss is expected to become the strongest
SAP ABAP 中的模块化:宏、子程序和功能模块 -04
畅享高性能计算!天翼云HPC解决方案来了
Unity game optimization (version 2) learning record 8
How to embody the value of knowledge management in business
C语言贪吃蛇
C language learning -18-makefile file writing examples and how to generate and call dynamic libraries
ORB_VI思想框架
phantomJs使用总结
GD32F4xx MCU 驱动mcp2515扩展CAN接口
ironSource Luna 推出苹果搜索广告限时优惠,注册即享3个月免费服务
洛谷P2466 [SDOI2008] Sue 的小球 题解
B树和B+树
Runtime -- explore the nature of classes, objects, and classifications
Binary search (integer binary)
Linux安装mysql
谷歌浏览器的小细节
信创研究:国产数据库聚焦信创市场,华为Gauss有望成为最强
Discover the number of media new users can insert