数据结构(4):图解递归调用机制
package com.Exercise.DataStructure_Algorithm.Recursion; public class RecursionTest1 { public static void main(String[] args) { test1(3); int res = test2(3); System.out.println(res); } public static void test1(int n){ if(n > 2){ test1(n-1); } System.out.println("n="+n); } public static int test2(int n){ if(n == 1){ return 1; }else{ return test2(n-1) * n; } } }