Hi
Please help me with this code....
class EasyOver
{
public static void main(
String args[])
{
float f=10f;
Long l=10l;
go(l);//line 1
go(f);//line 2
}
static void go(long... i)//line 3
{
System.out.println("long");
}
static void go(double... d)//line 4
{
System.out.println("var args double");
}
static void go(float... d)//line 5
{
System.out.println("var args float");
}
}
I am getting the following compiler error
at line 1: reference to go is ambiguous, both method go(double...) in
EasyOver and method go(float...) in EasyOver match
go(l);
at line 2: reference to go is ambiguous, both method go(double...) in
EasyOver and method go(float...) in EasyOver match
go(f);
My Question is:
1. when I make call to go() in line 1 it shld call go(long... l) right? why it gives me an error.
2. In line 2 I dont understand why I get the compiler error because 'f' is a float variable and it shld call go(float... f) right?
but when I change the code to the following I dont get any compiler error
class EasyOver
{
public static void main(String args[])
{
float f=10f;
Long l=10l;
go(l);//line 1
go(f);//line 2
}
static void go(long... i)//line 3
{
System.out.println("long");
}
static void go(Double d)//line 4
{
System.out.println("var args double");
}
static void go(Float d)//line 5
{
System.out.println("var args float");
}
}
I get the o/p
long
var args float
Please help me ranchers
Thanks
Srividhya