Hello everybody,, this is a simple java method that calls itself,,
class ex{
public static void main(String [] args){
simpleMeth(5);
}
static void simpleMeth(int i){
if(i != 0){
rec(--i);
System.out.println(i);
}
}
}
If you follow the the codes you will find after sending number (5) to the method then will be tested by the if statement(line n.6) then comes again to the method(line n.7) so (i) will be 4, and will continues until (i) equals 0,,but why after ending the if statement and comes to the method end brace,returns again to the printing statement and printns (0) then goes to line n.10 and adds one to (i) and returns again to line n.8 and so until (i)equals 4 ..
the result is:
0
1
2
3
4
Hope understand what i mean :)
Thnx..