package cn.com; //可变参数的应用 //自动将这些参数封装成了数组!!!可用于同一类型多参数传递!!! public class Test4 { public static void main(String[] args) { String [] strArr1=new String []{"f","ae","AD"}; String [] strArr2=new String []{"f","ae","AD","asdfasd"}; varStringArray(strArr1); varStringArray(strArr2); } public static void varStringArray(String...strings){ System.out.println("可变参数的长度为="+strings.length+",每个参数如下:"); for(int x=0;x<strings.length;x++){ System.out.println(strings[x]); } } }