public class array1{ public static void main(String [] args) { makeArray(1,3,4,5); } public static void makeArray(int ... arg) { for(int x=0;x<arg.length;x++) { System.out.print(arg[x]+" ,"); } for(int y:arg) { System.out.print(y+" ,"); } } }
第二种for是foreach的用法