public static void fun(int x){
System.out.println(x);
x--;
if(x > 0){
fun(x);
}
System.out.println("returning " + x);
}
in the main class: fun(5);
output:
5
4
3
2
1
returning 0
returning 1
returning 2
returning 3
returning 4
---------------------------------------
what i don't get is how the print statement is able to print 5 times when i think the method ends with x = 0, and the print statement only executes once after. can somebody please explain how this works??