[프로그래머스]문자열을 정수로 바꾸기

mongs_Develop·2022년 5월 7일
0

Programmers-Level1-Java

목록 보기
18/30
post-thumbnail
  • 문제 & 예시

  • 소스코드

// 문자열을 정수로 바꾸기
public class test18 {
	public static void main(String[] args) {
		Solution18 sol = new Solution18();
		String s = "-1234";
		System.out.println(sol.solution(s));
	}
}
class Solution18 {
    public int solution(String s) {
        int answer = 0;
       
        // 문자열을 정수형으로 변환
        answer = Integer.parseInt(s);
        
        return answer;
    }
}
  • consol
profile
개 발 인생

0개의 댓글