I am new to Recursion in Java and came across this code in a textbook. After running the code it prints "1 2 3 4 5" and am wondering why it doesn't print "5 4 3 2 1"?
public class Test {
public static void main(String[] args) {
xMethod(5);
}
public static void xMethod(int n) {
if (n > 0) {
xMethod(n - 1);
System.out.print(n + " ");
}
}
}