Originally posted by Saurabh Vyas:
Thus compiler is showing ambiguous method call error during compilation of our original problem. B�cos compiler is confused as to which type of array it should convert the arguments of vararg method.
class Vararg {
static void vararg(long ... x)
{ System.out.println("long..."); }
static void vararg(Integer ... x)
{ System.out.println("Integer..."); }
public static void main(String [] args) {
int i = 5;
vararg(5,5);
}
}
?
--------------------
Thanks
Sanjeev KS
Posts: 60 | Registered: Nov 2006 | IP: Logged
Jae Stryker
greenhorn
Member # 137135
posted November 07, 2006 01:46 AM Profile for Jae Stryker Send New Private Message Edit/Delete Post Reply With Quote It doesn't compile.
However I've changed the code slighty to try and help you along
code:
class Vararg {
static void vararg(String ... x)
{ System.out.println("String..."); }
static void vararg(Integer ... x)
{ System.out.println("Integer..."); }
public static void main(String [] args) {
int i = 5;
vararg(i,i);
String testOne = "TestOne";
String testTwo = "TestTwo";
String testThree = "TestThree";
//vararg(testOne,testTwo,testThree); Now there is no Error
}
}
I agree with Saurabh as this program dosen't produce any error , if we do not attempt to call these ambiguous overloaded methods