class Demo1 {
public static void main(
String args[]) {
myMethod(5); // pass positive integer
}
static void myMethod( int counter)
{
if(counter == 0)
return;
else{
System.out.println("hello " + counter);
myMethod(--counter);
System.out.println(" "+counter);
return;
}
}
}
produces result
hello 5
hello 4
hello 3
hello 2
hello 1
0
1
2
3
4
Please explain how 0 to 4 are printed?