public class Demo04 { public static void main(String[] args) { Demo04 demo04 = new Demo04(); demo04.test(1,2,3); } public void test(int... i){//int x,int...i必须在最后 System.out.println(i[0]); System.out.println(i[1]); } }
public class Demo06 { //2! 2*1 //5! 5*4*3*2*1 public static void main(String[] args) { System.out.println(f(5)); } public static int f (int n){ if (n==1){ return 1; }else { return n*f(n-1); } //边界条件:边界 //前阶段:参数不等于1就不停调用自身 //返回阶段n(n-1) } }