文章目录
可变长度参数简介
package ReflectClass;
public class Test03 {
public static void main(String[] args) {
m(1,2,3,4,5,6,7);
// m2(1,"我","是","中","国","人","民");
// String[] strings={"我","是","中","国","人","民"};
String [] strings = new String[]{"我","是","中","国","人","民"};
m2(1,strings);
}
public static void m(int... args){
for (int i=0;i<args.length;i++){
System.out.print(args[i]+" ");
}
}
public static void m2(int a,String... args){
System.out.println(a);
for (int i=0;i<args.length;i++){
System.out.print(args[i]+" ");
}
}
}