File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array Vs VarArgs Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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: 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[].
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Array Vs VarArgs
 
Similar Threads
a program on wrapper classes
array and vararg overloading confusion
Overloading Ambiguously
Switch case Compiler error
ambiguous compile-time error with varargs