File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Make it so: Java DB Connections & Transactions this week in the JDBC 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

Syntax of Array as parameter in JDK 1.6

Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132


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

Joined: Jan 28, 2003
Posts: 4181

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

See This Page for more info.

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.
I agree. Here's the link:
subject: Syntax of Array as parameter in JDK 1.6
It's not a secret anymore!