Algorithm/프로그래머스

[알고리즘] 대문자와 소문자 Java

rw- 2023. 4. 10. 22:33
728x90

 

 

import java.util.Arrays;
import java.util.stream.Collectors;

class Solution {
    public String solution(String my_string) {
        return Arrays.asList(my_string.split("")).stream()
            .map(s -> s.charAt(0) > 96 ? s.toUpperCase() : s.toLowerCase())
            .collect(Collectors.joining());
    }
}

 

 

 

728x90
반응형