aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Q on variable arity parameter :-) 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 "Q on variable arity parameter :-)" Watch "Q on variable arity parameter :-)" New topic
Author

Q on variable arity parameter :-)

Peter Gade Christensen
Greenhorn

Joined: Sep 23, 2006
Posts: 25
yeah sorry variable args ... The K&B book says variable args are defined like so ...pg 47 SCJP5

"Follow the type with an ellipsis (...) and a space and then the name of the array that will hold the parameters"

I did a couple of experiments - doesn't seem like the compiler holds us to one space between the ellipsis and the parameters -


All of these seem to work well - Any pointers to what is the correct syntax?

Thanks!!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Whitespace is not significant in Java except where it serves to delineate tokens. In this case, no whitespace is actually needed at all, so (String...args) is perfectly correct. But the convention is a single space after the dots.


[Jess in Action][AskingGoodQuestions]
Peter Gade Christensen
Greenhorn

Joined: Sep 23, 2006
Posts: 25
Originally posted by Ernest Friedman-Hill:
Whitespace is not significant in Java except where it serves to delineate tokens. In this case, no whitespace is actually needed at all, so (String...args) is perfectly correct. But the convention is a single space after the dots.


cool thnaks !!!
Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
Yes that's agreed , then K&B should not have added in the basic syntax.

The basic syntax should be :

<type>...<array-name>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q on variable arity parameter :-)