递归头(边界条件):什么时候不调用自身。
递归体:
返回阶段:返回值传递。
//理解篇:
public class Demo06 {
public static void main(String[] args) {
Demo06 test = new Demo06();
test.test();
}
public void test()
{
test();
}
}
//应用篇:
public class Demo07 {
public static void main(String[] args) {
System.out.println(f(5));//5的阶层。
}
public static int f(int n)
{
//递归头
if (n==1)
{
return 1;
}else{
//递归体
return n*f(n-1);//返回
}
}
}
一个方法只能有一个可变参数。
可变参数必须放在最后。
值传递和引用传递的区别:
//java是值传递
原文:https://www.cnblogs.com/hanxinlaziji/p/12806157.html