출처: https://bumcrush.tistory.com/182 [맑음때때로 여름]

참고 링크  : pridiot.tistory.com/24

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
        char arr[] = {'D''W''O''A''B'};
        // 모두 소문자로 변경한 후 출력하라.
        // A=65, a=97 -> 32 
        // System.out.println("ASCII = " + (int)arr[0]);  알파벳을 ASCII 코드로변경해서 출력해보기
        
        int asc = (int)arr[0];    // D의 ASCII코드값 얻기
        asc = asc+32;            // 소문자로 변환        
        char ch = (char)asc;    // 문자로변환
        System.out.println(ch); // 출력
        
        for(int i=0 ; i<arr.length ; i++) {
            char c = arr[i]; // char c에 순서대로 알파벳 넣기
            int asc2 = (int)c; // arr[i]값의 ASCII 코드값 얻기
            asc2 = asc2+32// 소문자로 변환하기
            arr[i] = (char) asc2; // 다시 arr[i]에 소문자로 바뀐 값 넣어주기
            System.out.print(arr[i]);
            
        }
cs

+ Recent posts