-Code
class Solution {
public int solution(String num_str) {
int answer = 0;
for (char n : num_str.toCharArray()) {
answer += n - '0';
};
return answer;
}
}
'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
[프로그래머스/Java] 뒤에서 5등 위로 (0) | 2025.02.05 |
---|---|
[프로그래머스/Java] 정수 부분 (0) | 2025.02.05 |
[프로그래머스/Java] 문자열을 정수로 변환하기 (0) | 2025.02.05 |
[프로그래머스/Java] 문자열로 변환 (0) | 2025.02.05 |
[프로그래머스/Java] 공배수 (0) | 2025.02.05 |