java - Recursion inside while loop, How does it work? -


Can you please tell how this Java code works? :

  public square key {public static zero major (string [] args) {strangemouth (5); } Public static zero strangometer {while (Lennon> 1) {System.out.println (len-1); Strangemouth (lane -1); }}  

I tried to debug it and followed the code according to the phase, but I did not understand this.

Update: Sorry I did not mention it. I know the result of this code, but just want to know the steps of execution.

That 'Ll 4 3 2 1 1 1 1 1 1 ...

and was stranded in a loop because sometime ago in the loop The lane has not been modified. The first call (= 5, 4, 3, with the lane) goes through a loop intrusion, and are waiting for Strangemand's return. When lane = 2, then while the loop string meth (1) calls, and since the lane is not greater than 1, then when the loop ends and it returns the call. But LAN is still in the 2 remaining whale loop, so it is called Stramometh (2) again and again. and then.

If () is more useful than ().


Comments