| Author |
overloading
|
vineet walia
Ranch Hand
Joined: Feb 16, 2008
Posts: 138
|
|
please explain this problem?
|
 |
Himanshu Kansal
Ranch Hand
Joined: Jul 05, 2009
Posts: 257
|
|
Well, the problem is that you did not tell the problem.
So please let us execute a getter method on you to retrieve the problem statement. In short, what problem are you facing?
|
Experience and talent are independent of age
|
 |
Sebastian Janisch
Ranch Hand
Joined: Feb 23, 2009
Posts: 1183
|
|
The problem is that he is facing an ambiguity compilation error because the compiler does not know which of the methods to invoke.
At runtime, var-args turn into an array, in your case int[] and Integer[]. The compiler could promote your invocation argument into both Integer[] and int[], hence does not know what to choose.
If you used new int[] {SOME VALUE} or new Integer[] {SOME_VALUE}, it would work.
|
JDBCSupport - An easy to use, light-weight JDBC framework -
|
 |
vineet walia
Ranch Hand
Joined: Feb 16, 2008
Posts: 138
|
|
Himanshu Kansal wrote:Well, the problem is that you did not tell the problem.
So please let us execute a getter method on you to retrieve the problem statement. In short, what problem are you facing?
are yaar complietime error kyu de raha ha ye ?
int wala rum hona chy what i think?
|
 |
vineet walia
Ranch Hand
Joined: Feb 16, 2008
Posts: 138
|
|
Sebastian Janisch wrote:The problem is that he is facing an ambiguity compilation error because the compiler does not know which of the methods to invoke.
At runtime, var-args turn into an array, in your case int[] and Integer[]. The compiler could promote your invocation argument into both Integer[] and int[], hence does not know what to choose.
If you used new int[] {SOME VALUE} or new Integer[] {SOME_VALUE}, it would work.
thanks Sebastian Janisch
|
 |
Himanshu Kansal
Ranch Hand
Joined: Jul 05, 2009
Posts: 257
|
|
hehe! okay. Sebastian answered it already.
it is just a matter of conversions and matching. If it is between Integer and int, the compiler matches the nearest. But arrays being objects confuse it, as it is to be resolved at compile time itself. If you give it a specific array of Integers or ints, it'll be easy as Sebastian said.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
vineet walia wrote:
Himanshu Kansal wrote:Well, the problem is that you did not tell the problem.
So please let us execute a getter method on you to retrieve the problem statement. In short, what problem are you facing?
are yaar complietime error kyu de raha ha ye ? (But buddy why is it giving a compilation error)
int wala rum hona chy what i think? (the int version should run I think)
vineet please Quote Your Sources when you post a question.
Also why are you writing in Hindi, not everyone understands Hindi, in the future try to write in English...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
 |
|
|
subject: overloading
|
|
|