wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes var args doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "var args doubt" Watch "var args doubt" New topic
Author

var args doubt

aditi mudholkar
Greenhorn

Joined: Feb 26, 2007
Posts: 7
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

Joined: Feb 07, 2005
Posts: 2367
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

Joined: Feb 26, 2007
Posts: 7
yes i know the syntax. but the code like

void display(int num,string ....args)
what does the .... imply???
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
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


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: var args doubt
 
Similar Threads
Vararg Problem
Varargs overloading problem
Constructor Basics Doubt. K &B Pg131
Question about Boxing
var-args overloading compiler error: ambiguous