1 /* 2 1.可变个数的形参的方法与同名的方法之间可以构成重载 3 2.可变个数的形参的个数从0个到无穷个 4 3.当enen()和enen(String...s)构成重载时,调用方法时,若参数为空,默认调用enen() 5 4.可变个数的形参声明在参数列表的最后面,且有且只有一个 6 5.enen(String[])和enen(String...)不能构成重载 7 6.类似enen(int,String[])和enen(int,String...)也不能构成重载 8 7.若存在enen(String...),则有限个数的形参的方法都可以省略,当然,若它们存在,调用方法时,优先调用它们。比如存在enen(String s),调用方法enen("hehe"),就是调用enen(String s) 9 */ 10 class hehe 11 { 12 public static void main(String[] args) 13 { 14 Person p=new Person(); 15 p.enen("hehe"); 16 } 17 18 19 } 20 21 class Person 22 { 23 public void enen() 24 { 25 System.out.println("无参数"); 26 } 27 28 public void enen(int a) 29 { 30 System.out.println("参数为int"); 31 } 32 33 public void enen(String s) 34 { 35 System.out.println("参数为String"); 36 } 37 38 39 40 //无法在Person中同时声明enen(String[])和enen(String...) 41 public void enen(String...s) 42 { 43 System.out.println("参数为String数组"); 44 } 45 46 /*public void enen(String[] s) 47 { 48 System.out.println("参数为String数组"); 49 }*/ 50 51 52 //无法在Person中同时声明enen(int,String[])和enen(int,String...) 53 /*public void enen(int a,String...s) 54 { 55 System.out.println("参数为int+String可变个数形参"); 56 }*/ 57 public void enen(int a,String[]s) 58 { 59 System.out.println("参数为int+String数组"); 60 } 61 }