Study with me/프로그래머스 L0 마스터하기
프로그래머스 - L0 숨어있는숫자의덧셈(1)
외계나무
2023. 11. 9. 11:30
프로그래머스 - level 0 숨어있는 숫자의 덧셈 (1)
class Solution {
public int solution(String my_string) {
int answer = 0;
String[] eachOne = my_string.split("");
for(String one : eachOne) {
try {
answer += Integer.parseInt(one);
} catch (Exception ignored) { }
}
return answer;
}
}
try - catch 연습!