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);
}
}
}
运行结果:
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);
}
}
}
运行结果: