wood burning stoves 2.0*
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
Author

varagrs

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?

test1(1,2,3,x,y,z,3.0)


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

Joined: Apr 06, 2010
Posts: 4375
    
    8

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:
Now...is that 3 arguments in a and none in b? Or 2 in a and 1 in b? Or what?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

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: http://aspose.com/file-tools
 
subject: varagrs