Advertisement

Java代码 基础算法 练习 字母转换 2024年7月23日

阅读量:

任务描述:
通过键盘输入一组字符(字符串长度限制为255以内),要求将其中所有大写字母转换为小写字母,同时将小写字母转换为大写字母。

复制代码
 package a4_2024_07;

    
  
    
 import java.util.Scanner;
    
  
    
 public class j240723_1 {
    
     public static void main(String[] args) {
    
     Scanner sc = new Scanner(System.in);
    
     System.out.println("输入一个字符串:");
    
     String str = sc.nextLine();
    
  
    
     // 使用StringBuilder来构建新的字符串
    
     StringBuilder result = new StringBuilder();
    
  
    
     for (int i = 0; i < str.lengt

全部评论 (0)

还没有任何评论哟~