| Author |
Array Vs VarArgs
|
Harikrishna Gorrepati
Ranch Hand
Joined: Sep 23, 2010
Posts: 422
|
|
Hi, The following question is from whizlabs..Why I am getting compile error as mentioned in the comments ?
|
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
|
 |
Ram Narayan.M
Ranch Hand
Joined: Jul 11, 2010
Posts: 244
|
|
Here, the base address of array i.e., first element of array's address referred by "i" is passed as argument in test()...
What the varargs expects is multiple arguments which is of "int" data type...
It has to be passed like
test(1,2,3,4)
(or)
test(1,2,3,4,5)
(or)
Likewise upto n times...
|
SCJP 6 [SCJP - Old is Gold]
|
 |
Sudhakar Sharma
Ranch Hand
Joined: Apr 04, 2009
Posts: 71
|
|
Harikrishna Gorrepati wrote:Hi, The following question is from whizlabs..Why I am getting compile error as mentioned in the comments ?
Hi,
Because there is not the matching method signature.
The rule is Integer can be unboxed to an int, but Integer[] cannot be unboxed to an int[].
|
 |
 |
|
|
subject: Array Vs VarArgs
|
|
|