I am learning Java and in one of the recursion example the following code is used and I am not getting that why the print statement starts printing j from 1 instead of 10?
class Test {
void printtest(int j) {
if(j==0)
return;
else
printtest(j-1);
System.out.println(j);
}
}
public class RecursionTest {
public static void main(String args[]) {
Test t = new Test();
t.printtest(10);
}
}
Output:
1
2
3
4
......10