Can we mix var-arg parameter with normal paramter?

class VarArgMethod5
{
public static void m1(String s,int...x)
{
System.out.print(s+" ");
for(int i:x)
System.out.print(i+" ");
System.out.println();

}
public static void main(String[] args)
{
m1("altaf");
m1("altaf",10);
m1("altaf",10,20);
}
}
/*
Output:- Compilation error
Explanation:- If we mix var-arg parameter with normal parameter then var-arg parameter should be
the last parameter otherwise it will rise compilation error.
*/

0 comments: