web123456

In Java, the letters in the input string are case interchanged

import java.util.*; /** * @author lihao * @Date 2022/9/24 19:08 */ public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String temp = sc.nextLine(); //The form before case conversion System.out.println(temp); StringBuffer sb = new StringBuffer(); for(int i=0;i<temp.length();i++){ char c=temp.charAt(i); if(c>='A' && c<='Z'){ c+=32; }else{ c-=32; } sb.append(c); } //The form after upper case conversion System.out.println(sb); } }