String 클래스에 문자열을 대소문자로 변환할 수 있는 함수가 제공된다.

 

toLowerCase : 모든 문자열을 소문자로 변환

toUpperCase : 모든 문자열을 대문자로 변환

public class String_toCaseTest {
 
    public static void main(String[] args) {
        String str = "Hello World";
        String substr1 = str.toLowerCase();
        String substr2 = str.toUpperCase();
        
        System.out.println(substr1); //hello world
        System.out.println(substr2); //Hello World
    }