Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: public static void main(String... args)???

  1. #1
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Question public static void main(String... args)???

    Hello All!

    I"m working with some source code and am seeing the title above as the main line:

    public static void main(String... args) {

    I'm unclear on what the ellipsis is used for in this example... as I learned that ths line should be written as:

    public static void main(String[] arguments) {

    ... however when I go to compile the file, i get no complaints??? I attempted to google "String... args" but get nothing really relevant. Can someone shed some light on this? is "String..." the same as "String[]" and is "args" the same as "arguments" ?

    Thanks!

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: public static void main(String... args)???

    Stands for many arguments of the same sort... apparently is the same as Strings[]. I would use the [] syntax...

    It is called 'varargs' - take a look here: Varargs

  3. #3
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Default Re: public static void main(String... args)???

    Thanks for the info!

    After reading the link you provided, I think i understand that the "args" is used for multiple arguments.

    But you mention using "Strings[]" ... is that the same as "String[]" ? I only ask because the link you provided only shows the "String[]" without the plural "s'.

    Thanks for the clarification!

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: public static void main(String... args)???

    Quote Originally Posted by SnakeDoc View Post
    But you mention using "Strings[]" ... is that the same as "String[]" ?
    It's a typo. He meant String[]

    db
    Sierra likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Default Re: public static void main(String... args)???

    Ok thanks!

    :-)

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: public static void main(String... args)???

    Deleted a post that adds no value whatsoever to this old and answered thread. rasmita4, please check the date on an old thread and don't post again until you have gone through these three links:
    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum - Learn Java Programming

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Q?> about public static void main(String args[])
    By boblingwide in forum New To Java
    Replies: 4
    Last Post: 03-23-2012, 11:17 AM
  2. Replies: 10
    Last Post: 07-10-2011, 08:37 AM
  3. Public static void main (String args[])
    By arefeh in forum New To Java
    Replies: 12
    Last Post: 01-28-2010, 11:58 AM
  4. Replies: 9
    Last Post: 11-22-2008, 11:03 PM
  5. Replies: 5
    Last Post: 10-06-2008, 12:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •