• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Syntax of Array as parameter in JDK 1.6

 
Rahul Shilpakar
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Steve Luke
Bartender
Pie
Posts: 4181
21
IntelliJ IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ... notation denotes 'varargs'. You are passing some number of Strings into the method,

See This Page for more info.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic