• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Syntax of Array as parameter in JDK 1.6

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic