본문 바로가기
Beakjoon&프로그래머스/Java

[프로그래머스/Java] 자릿수 더하기

by 현장 2025. 2. 17.

-Code

import java.util.Arrays;

class Solution {
    public int solution(int n) {
        return Arrays.stream(Integer.toString(n).split(""))
                .mapToInt(Integer::parseInt).sum();
    }
}