My method is for example, supposed to output 123 if int[] num123 = {1,2,3}; in the main method. It is outputting zero instead. In the convert num method when I change that last zero it just outputs whatever number it was replaced with. We are not allowed to use any loops so that is what has me stumped.
public int convertNum(int[] num) {
return numHelper(num, 0, num.length - 1, 0);
}
private int numHelper(int[] num, int atIndex, int lastIndex, int result) {
atIndex = num.length - 1;
if (atIndex == lastIndex) {
return result;
}
if (num.length > 0) {
atIndex += 1;
}
return (int) (num[atIndex] * Math.pow(10, lastIndex - atIndex))
+ numHelper(num, atIndex + 1, lastIndex, result);
}