This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Syntax of Array as parameter in JDK 1.6 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 » Java » Beginning Java
Bookmark "Syntax of Array as parameter in JDK 1.6" Watch "Syntax of Array as parameter in JDK 1.6" New topic
Author

Syntax of Array as parameter in JDK 1.6

Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132

Hi,

I am using jdk 6 compilation.
I have seen an example which has a method like follow



My Questions are:
1) Why jdk 6 uses notation '...' insted of '[]' notation at LINE 2 ? Is there any particular significance or reason?
2) What is advantage of this '...' sign.
3) If i make same notation at LINE 1 its giving me compilation error. Why? Does it used for passing parameter notation?


I don't have have any idea about that notation. Please tell me about it. I also run above program and it compiles fine.
I also saw this notation in one Question of SCJP 1.6 Version.


Perform for today. Adapt for tomorrow.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4165
    
  21

The ... notation denotes 'varargs'. You are passing some number of Strings into the method,

See This Page for more info.


Steve
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

You can also check out this article on the subject. And if you go to this link, you can download chapter 5 of Java 1.5 Tiger: A Developer's Notebook. That chapter is on varagrs.
 
Don't get me started about those stupid light bulbs.
 
subject: Syntax of Array as parameter in JDK 1.6
 
Similar Threads
Behavior of primitive types when incremented beyond their max limit
Exceptional Handling Question
Strange recursive method call! ???
static class query