java小递归

  • 内容
  • 评论
  • 相关
package javaapplication1;

/**
 *
 * @author hellogxp
 */
public class Father {
    protected String name;
    
    public static void main(String[] args) {
        Father.eat();
        Params params = new Params();
        params.params(1, "para1", "para2");
        Bingxing bingxing = new Bingxing();
        int data = bingxing.fn(10);
        System.out.println(data);
    }
    
    public static void eat() {
        System.out.println("eat");
    }
}

class Bingxing {

    public int fn(int i) {
        if (i == 0) {
            return 0;
        } else if (i == 1) {
            return 1;
        }else{
            return 2*fn(i-1)+fn(i-2);
        }
    }
}
package javaapplication1;

/**
 *
 * @author hellogxp
 */
public class Params {
    public static void main(String arg[]) {
        
    }
    
    public void params(int a, String... books) {
        for(int i =0; i < books.length; i++){
            System.out.println(books[i]);
        }
    }
    
    
}

评论

0条评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注