[프로그래머스/Java] Lv.1 문자열 다루기 기본
문제 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 class Solution { public boolean solution(String s) { boolean answer = true; if (s.length() == 4 || s.length() == 6) { //길이가 4 or 6이면 try { Integer.parseInt(s); //s를 integer로 변환을 시도 answer=true; } catch (NumberFormatException nfe) { //integer변환을 시도했는데 문자가 포함되어있으면 예외 발생 answer=false; } }else { //길이가 4 or 6이 아니면 answer=false; } return answer; } } Colored..