File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes varagrs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "varagrs" Watch "varagrs" New topic


Mohtashim Shaikh
Ranch Hand

Joined: Jul 18, 2010
Posts: 43
We cannot have two varags and a string passed in the same method. If not why?


void test1(int... x, char... z, double d)
Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

The restriction on variable arguments is that you can only have one single var-arg parameter, and it must be the last argument. That's to make it easier/possible for the compiler to work out which ones are part of the variable parameters. For example: that 3 arguments in a and none in b? Or 2 in a and 1 in b? Or what?
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11923

You can only have ONE variable argument list in a method, and it must be the last one in the declaration.

type doesn't matter.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: varagrs
It's not a secret anymore!