解释:程序调用自身的编程技巧叫做递归。
package org.wxp.recursion;  
  
/** 
 * 计算5的阶乘(result = 5*4*3*2*1) 
 * @author Champion.Wong 
 *  
 * 
 */  
public class Test01 {  
    public static void main(String[] args) {  
        System.out.println(f(5));  
    }  
      
    public static int f(int n) {  
        if (1 == n)   
            return 1;  
        else   
            return n*(n-1);  
    }  
}  

package org.wxp.recursion;  
/** 
 * 求数列:1,1,2,3,5,8......第40位的数 
 * @author Champion.Wong 
 *  
 */  
public class Test_02_Fibonacci {  
    public static void main(String[] args) {  
        System.out.println(f(6));  
    }  
      
    public static int f(int n ) {  
        if (1== n || 2 == n)   
            return 1;  
        else  
            return f(n-1) + f(n-2);  
    }  
}  
 

原文:http://www.cnblogs.com/gxbk629/p/4022716.html