Does it Possible?
카테고리 없음 / 2009. 7. 14. 08:18
package recursion;
public class Main {
public static void main(String[] args) {
System.out.println(processDigits(321));
System.out.println(processDigitsRecursively(321));
}
Problem is here~
private static String processDigitsRecursively(int number) {
String temp = "";
if(number < 10)
return toString(number);
else
return processDigitsRecursively(number / 10) + toString(number % 10);
}
return method1() + method2(); << I have never seen this return value.
Is it possible?
private static String toString(int digit) {
switch(digit) {
case 1:
return "one";
case 2:
return "two";
case 3:
return "three";
default:
return "ERROR";
}
}
}