posted 15 years ago
Garima,
Overloading, compilation wise, is fine here. But usage wise, its not fine. Because, at the end, you are unable to call these methods because of the ambiguity issue, as there is varargs in one call and the other is boxing+varargs...
One way of solving this issue would be to change the first callMethod to public static void callMethod(Integer i){ (removal of varargs syntax)...that way, you will get Primitive as the output.
Another option is to remove the varargs from the second call. Or else, in the parameters you are passing, do not pass variables that involve unboxing...
Solutions are many...But, with the same exact code you have given, I don't think you can call those methods.