aspose file tools
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
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 "Variable length argument list. Java 5.0" Watch "Variable length argument list. Java 5.0" New topic
Author

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
Rancher

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

http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html
Marcus


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
 
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: Variable length argument list. Java 5.0
 
Similar Threads
method question
static method invocation problem
Passing arguments in multiple lines
Failed to copy two dimensional array