숨어있는 숫자의 덧셈(1)

han.user();·2023년 3월 30일
0

프로그래머스

목록 보기
5/87
post-thumbnail

class Solution {
    public int solution(String my_string) {
        int answer = 0;
        
        for (int i = 0; i < my_string.length(); i++) {
            char ch = my_string.charAt(i);
            if (Character.isDigit(ch)) {
                answer += Character.getNumericValue(ch);
            }
        }
        
        return answer;
    }
}
profile
I'm still hungry.

0개의 댓글