class Solution { public String solution(int age) { String answer = ""; int caseNum = 0; String reversAnswer = ""; while(age>0){ caseNum = age%10; age=age/10; switch(caseNum){ case 1 : reversAnswer+='b'; break; case 2 : reversAnswer+='c'; break; case 3 : reversAnswer+='d'; break; case 4 : reversAnswer+='e'; break; case 5 : reversAnswer+='f'; break; case 6 : reversAnswer+='g'; break; case 7 : reversAnswer+='h'; break; case 8 : reversAnswer+='i'; break; case 9 : reversAnswer+='j'; break; case 0 : reversAnswer+='a'; break; } } for(int i = reversAnswer.length()-1; i >= 0 ; i--){ answer +=reversAnswer.charAt(i); } return answer; } }
class Solution { public String solution(int age) { String answer = ""; String[] alpha = new String[]{"a","b","c","d","e","f","g","h","i","j"}; while(age>0){ answer = alpha[age % 10] + answer; // 이렇게 하면 자동으로 역순 string 완성됨. age /= 10; } return answer; } }