Can we use multiple var-arg paramteter in a method?
class VarArgMethod6
{
public static void m1(String...s,int...x)
{
System.out.println("double var-arg method");
}
public static void main(String[] args)
{
m1();
m1("altaf",10);
m1("altaf","ravi",10,20);
}
}
/*
Output:- Compilation error
Explanation:- In var-arg method we can take only one var-arg parameter otherwise we will get compilation error.
*/
{
public static void m1(String...s,int...x)
{
System.out.println("double var-arg method");
}
public static void main(String[] args)
{
m1();
m1("altaf",10);
m1("altaf","ravi",10,20);
}
}
/*
Output:- Compilation error
Explanation:- In var-arg method we can take only one var-arg parameter otherwise we will get compilation error.
*/
0 comments: