JAVA的转换大写
package com.gx.copydemo;
import java.util.HashMap;
import java.util.Map;
/**

  • 不使用toUpperCase()和toLowerCase()的方法情况下,怎么把一段英文字母大写
  • @author QMT

*/
public class Demo {

public static void main(String[] args) {
String str=“abcABC”;
char[] chars=str.toCharArray();
for (int i = 0; i < chars.length; i++) {
if (chars[i]>‘a’-1&&chars[i]<‘z’+1) {
chars[i]-=32;//大于A小于Z +32 //大于a小于z -32
}
}
System.out.println(new String(chars));
运行效果:
JAVA的转换大写

相关文章:

  • 2022-01-21
  • 2022-12-23
  • 2021-12-01
  • 2021-12-09
猜你喜欢
  • 2021-10-18
  • 2021-11-26
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
相关资源
相似解决方案