Doubt related recursion

public class stackisbuilding {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	printdecreasing(5);
}
	public static  void printdecreasing(int n)
	{    if(n==0)
	{
		return ;
	}
		System.out.println(n);
		printdecreasing(n-1);
			System.out.println("*");
		
	}

}
in this program when base case is achieved then where the return statement will go? and why it is printing five times (*) in the output?

After the base case return statement, the flow will go back to the function with the value it called itself when the base case hit. Meaning, when n=1 called printdecreasing(0), base case got it and the function return itself back to when n was = 1.
‘*’ is printing 5 times because the function ran 5 times when n was = {1,2,3,4,5}. Everytime the function finishes its code, the flow of control goes back to the function and its value which called it. Thats why * was printed 5 times. First when n=1, then n=2, then n=3 , n=4 and last when n=5

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.