Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

var args doubt  RSS feed

 
aditi mudholkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi.
i have not been able to understand the var-args syntax and in what way should the var arg be the last of a method's argument.
could you explain with an example.
thanks
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by aditi mudholkar:
hi.
i have not been able to understand the var-args syntax and in what way should the var arg be the last of a method's argument.
could you explain with an example.
thanks


Basically this is correct.

,

but this is not

 
aditi mudholkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i know the syntax. but the code like

void display(int num,string ....args)
what does the .... imply???
 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can declare

public void static main(String... a){

}
thats means you can pass variable number of Strings each time you call main.
Is that clear.

like
java SampleProgram one two three
java SampleProgram write until you satisfy
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!