ALGORITHM

[JAVA] 알고리즘 : 문자열 - 대소문자 변환

연듀 2022. 6. 20. 11:21

 

import java.io.*;
import java.util.*;

public class Main {
    public String solution(String str){
        String answer = "";

        for(char x : str.toCharArray()){
            if(Character.isLowerCase(x)) answer+=Character.toUpperCase(x);
            else answer+=Character.toLowerCase(x);

         /*   if(x>=97 && x<=122)  answer+=(char)(x-32); // 소문자를 대문자로
            else answer+=(char)(x+32);*/
        }
        return answer;
    }
    public static void main(String[] args) throws IOException {
        Main T = new Main();
        Scanner kb = new Scanner(System.in);
        String str = kb.next();
        System.out.print(T.solution(str));
    }

}