wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Variable length argument list. Java 5.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Variable length argument list. Java 5.0" Watch "Variable length argument list. Java 5.0" New topic

Variable length argument list. Java 5.0

Rupak Khurana
Ranch Hand

Joined: Mar 01, 2005
Posts: 89
The following is valid :-

public void foo (int token, String ... strs) {}

however the next line is not.. why not...?

public void foo (String ... strs, int token) {}.. The compiler just reports "; expected at line ". The variable strs is treated as an array anyways and can hold zero or more arguments. So this syntax should be valid too....

any comments....

SCJP 1.5<br />SCWCD 1.4
Marcus Green
arch rival

Joined: Sep 14, 1999
Posts: 2813
A method can only have one variable length argument and it must be the last in the method signature. You can read more about this at


SCWCD: Online Course, 50,000+ words and 200+ questions
I agree. Here's the link: http://aspose.com/file-tools
subject: Variable length argument list. Java 5.0
It's not a secret anymore!