aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array Vs VarArgs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Array Vs VarArgs" Watch "Array Vs VarArgs" New topic
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: 247

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[].
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array Vs VarArgs