This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Campbell Ritchie wrote:No it isn't; it is simply impossible to tell which the last int for x is and which the first int for y is.
Thats a reason why Java prevented more than 1 var-args for a method.
What I wanted to say was...
int... x => any number of integers
int... y => any number of integers
Even if more than 1 var-arg was allowed for a method, you wouldn't want to use int... x,int... y , because int... x simply means the same and would satisfy the requirement as well.
No. For the method there is a real difference between x and y. So int... x, int... y is definitely not the same as int... xy.
Multiple varargs may sometimes be easy to detect (like String... s, int... i), but in too many cases (e.g. Object... o, String... s -- any String is also an object) there is just too much ambiguity. That's why only one is allowed.