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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
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
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
 
 
subject: Variable length argument list. Java 5.0