Can we replace var-arg parameter with 1-dimensional array?
class VarArgMethod9
{
public static void main(String[] args)
{
m1(10,20);
}
public static void m1(int[] x)
{
System.out.println("m1 method");
}
}
/*
Output:- Compilation Error
Explanation:- No, Wherever var-arg parameter is available, we cannot replace with 1-dimensional
array parameter but wherever 1-dimensional array is available we can replace
with var-arg parameter.
*/
{
public static void main(String[] args)
{
m1(10,20);
}
public static void m1(int[] x)
{
System.out.println("m1 method");
}
}
/*
Output:- Compilation Error
Explanation:- No, Wherever var-arg parameter is available, we cannot replace with 1-dimensional
array parameter but wherever 1-dimensional array is available we can replace
with var-arg parameter.
*/
0 comments: