public boolean solution(String s) {
if (s.length() == 4 || s.length() == 6) {
try {
Integer.parseInt(s);
return true;
} catch (NumberFormatException e) {
return false;
}
}
return false;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/12918