Why is recursion backwards when I call the function before printing but not if I print after calling the function?
For some reason I don't understand why the recursive method prints backward when it's the function is being called before the print and why is it not backward when I print before calling the function.
Could someone explain it to me?
public void tricky1(int n) {
if (n >= 0) {
System.out.print(n);
tricky1(n - 2);
}
}
Second
public void tricky2(int n) {
if (n >= 0) {
tricky2(n - 2);
System.out.print(n);
}
}