java中形参个数可变的方法使用

public class Varargs { public static void main(String[] args) { test(3,"java","C++","PHP"); } public static void test(int num,String... books) { System.out.println(num); for(String book : books) { System.out.println(book); } } }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzwffs.html