当前位置:网站首页>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());
}
}
边栏推荐
- SAP web service 无法使用 SOAMANAGER 登陆到SOA管理页面
- Runtime -- explore the nature of classes, objects, and classifications
- 小程序开发----自定义有效期缓存
- pymssql模块使用指南
- School enterprise alliance is on the way! Huawei cloud gaussdb has come to universities again
- SAP ABAP 报告编程-08
- Simulation of stack and queue
- C language learning -17- function is passed in as a parameter
- #进程地址空间
- Alibaba cloud middleware's open source past
猜你喜欢
New design of databend SQL planner

ironSource Luna 推出苹果搜索广告限时优惠,注册即享3个月免费服务

Make the text template in pycharm project support jinjia2 syntax

84. (cesium chapter) movement of cesium model on terrain

SAP ABAP 对话框编程教程:中的模块池-09

Runtime——探索类,对象,分类本质

数睿数据荣获第二届ISIG中国产业智能大会两项年度大奖

Unity游戏优化(第2版)学习记录8

数值类型和字符串之间的转换

Cross border integration, creativity and innovation to help improve the influence of cultural tourism night tour
随机推荐
Scala language learning-06-differences between name passing parameters, value passing parameters and function passing parameters
SAP ABAP 数据字典教程 SE11:表、锁定对象、视图和结构 -03
Deploy odoo to the server and configure it as a service
【山大会议】WebRTC基础之对等体连接
[single chip microcomputer] [make buzzer sound] know the buzzer and let it make the sound you want
[Huawei cloud to Jian Zhiyuan] the winning list of essay solicitation is released!
[Shanda conference] project introduces Redux
6.GUI(图形,填充)
数睿数据受邀参与南通企业数字化转型研讨会
Discourse 新用户可插入媒体的数量
Make the text template in pycharm project support jinjia2 syntax
School enterprise alliance is on the way! Huawei cloud gaussdb has come to universities again
谷歌浏览器的小细节
19、 Xv6 context switching (implementation of context switching; encapsulation and recovery of state machine)
Solve the problem of MySQL remote login permission
信创研究:国产数据库聚焦信创市场,华为Gauss有望成为最强
84.(cesium篇)cesium模型在地形上运动
#进程地址空间
数字人民币可以买理财产品了!建行APP在试点地区上线服务专区,实测体验如何?
odoo本地文档功能开发记录