Recursion inside while loop, How does it work ?

Posted by M.H on Stack Overflow See other posts from Stack Overflow or by M.H
Published on 2010-06-18T14:57:44Z Indexed on 2010/06/18 15:03 UTC
Read the original article Hit count: 267

Can you please tell me how does this java code work? :

public class Main {
    public static void main (String[] args)  {
        Strangemethod(5);
    }
    public static void Strangemethod(int len) {
        while(len > 1){
            System.out.println(len-1);
            Strangemethod(len - 1);
        }
}
}

I tried to debug it and follow the code step by step but I didn't understand it.

© Stack Overflow or respective owner

Related posts about java

Related posts about recursion