蓝桥杯大小写转换

import java.util.Scanner;

public class Convert {
    public static void main(String[] args) {
        Scanner scanner=new Scanner( System.in );
        String string=scanner.next();
        
        //字符串转化为字符数组string.toCharArray();
        char[] chars = string.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (chars[i]<'a') {
                chars[i]+=32;//大写转换为小写+32


            } else{

                chars[i]-=32;

            }

            System.out.printf("%s" ,chars[i] );
        }




        }


    }
上一篇:LeetCode:打印出该字符串中字符的所有排序的字符串数组


下一篇:理解Java反射