[프로그래머스/Java] Lv.0 문자열을 정수로 변환하기

febCho·2024년 3월 18일
0

코딩테스트

목록 보기
105/253
post-thumbnail

문제

숫자로만 이루어진 문자열 n_str이 주어질 때, n_str을 정수로 변환하여 return하도록 solution 함수를 완성해주세요.

- 제한사항

  • 1 ≤ n_str ≤ 5
  • n_str은 0부터 9까지의 정수 문자로만 이루어져 있습니다.

풀이

class Solution {
    public int solution(String n_str) {
        int answer = Integer.parseInt(n_str);
        return answer;
    }
}

결과

profile
Done is better than perfect.

0개의 댓글