대소문자 변환

드코미·2025년 8월 10일
post-thumbnail

toUpperCase() / toLowerCase()는 알파벳에만 영향을 주고, 숫자나 다른 문자는 그대로 둡니다.

// 문자 하나
char c1 = 'a';
char up1 = Character.toUpperCase(c1); // 'A'
char lo1 = Character.toLowerCase('Z'); // 'z'

// 문자열 전체
String s = "Hello World!";
String up = s.toUpperCase(); // "HELLO WORLD!"
String lo = s.toLowerCase(); // "hello world!"
System.out.println(Character.toUpperCase('a'));  // 'A'
System.out.println(Character.toUpperCase('3'));  // '3'  (변화 없음)
System.out.println(Character.toUpperCase(' '));  // ' '  (변화 없음)

System.out.println("3people".toUpperCase());      // "3PEOPLE"
System.out.println("3people".toLowerCase());      // "3people"
profile
할 수 있다!!!

0개의 댓글