Can anybody please explain how would the statement
System.out.println("["+(i-1)+"] " +values[i-1];
be executed as the printarray is recursive and when the value of i reaches 0 the return statement executes terminating the method completely.
posted 6 years ago
When i reaches 0, the return statement only means "return from this particular method call". Control will then be passed to the calling method (where i = 1), and when that ends it will pass control to the method that called that, and so on till it reaches the original method.