문자열 다루기 기본1 [프로그래머스] 문자열 다루기 기본 처음 코드는 이랬다. isNumeric 메서드에서 인자로 들어온 s를 실수로 파싱하고, 파싱이 잘되면 true, 파싱이 안되면 false를 리턴한다. 그리고 리턴값을 가지고 문자열인지 아닌지 판단한다. class Solution { public static boolean isNumeric(String s) { try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; } } public boolean solution(String s) { boolean answer = true; if(isNumeric(s)){ if(s.length()==4||s.length()==6){ answer = true; }e.. 2022. 12. 1. 이전 1 다음