public class Test {
public static int j = 0; public static void fun(int i){ System.out.print(" ok "+ j); j++; i--; if(i>=0){ fun(i); } else{ System.out.print(" ok "); } } public static void main(String[] args){ fun(9); }
结果:ok 0 ok 1 ok 2 ok 3 ok 4 ok 5 ok 6 ok 7 ok 8 ok 9 ok