Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Q on variable arity parameter :-)

 
Peter Gade Christensen
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Gade Christensen
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that's agreed , then K&B should not have added in the basic syntax.

The basic syntax should be :

<type>...<array-name>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic