Results 1 to 5 of 5
  1. #1
    AedonetLIRA is offline Member
    Join Date
    Oct 2010
    Posts
    22
    Rep Power
    0

    Default I plead ignorance

    Ok, I have been programming in java for a bit, but no matter where I look I can't find out what

    Java Code:
    String... args
    
    //example
    public static void main(String... args){}
    does. I'm guessing it's just shorthand for "accept all arguments of type string", but I want to make sure.

    Thanks for your help
    ~Aedon
    Last edited by AedonetLIRA; 11-23-2010 at 07:27 PM. Reason: silly error :)

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    its called varargs - read: Varargs

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    In your example main() accepts an array of string elements or a sequence of strings.

    Java Code:
        // valid
    main("foo", "bar");
    
    String[] arr = {"foo", "bar"};
        // also valid
    main(arr);

    It is called "varargs" and was described in the guide which accompanied the 1.5 release.

  4. #4
    tashimoto is offline Member
    Join Date
    Sep 2010
    Location
    Oregon, usa
    Posts
    69
    Rep Power
    0

    Default

    This might help explain it: Lesson: A Closer Look at the "Hello World!" Application (The Java™ Tutorials > Getting Started)

    (Scroll down to "The Main Method" section)

    Regards, Chris

    ---> I just learned something NEW, too! Thanks, eRaaaa and pbrockway2 !! :)
    Last edited by tashimoto; 11-23-2010 at 07:44 PM. Reason: Read previous posts... (we all posted at the same time!)

  5. #5
    AedonetLIRA is offline Member
    Join Date
    Oct 2010
    Posts
    22
    Rep Power
    0

Tags for this Thread

Posting Permissions

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