๐ 1. ๋์๋ฌธ์ ๋ฐ๊ฟ์ ์ถ๋ ฅํ๊ธฐ
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.next();
System.out.println(swapCase(a));
}
public static String swapCase(String str) {
StringBuilder result = new StringBuilder();
for(char c:str.toCharArray()) {
if(Character.isUpperCase(c) ) {
result.append(Character.toLowerCase(c));
} else if(Character.isLowerCase(c)) {
result.append(Character.toUpperCase(c));
} else {
result.append(c);
}
}
return result.toString();
}
}
โญ 2. ๋ฌธ์์ด ๋๋ฆฌ๊ธฐ
import java.util.Scanner;
public class pro {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.next();
for(char c : a.toCharArray()) {
System.out.println(c);
}
char[] charArray = a.toCharArray();
for(int i = 0; i<charArray.length; i++) {
System.out.println(charArray[i]);
}
sc.close();
}
}
์ฌ์ด ๋ฌธ์ ๋ผ์ ์ฝ๋ ๊ทธ๋๋ก