• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Variable length argument list. Java 5.0

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic