Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By JeffGrigg

Thread: What is the difference?

  1. #1
    sublixt's Avatar
    sublixt is offline Member
    Join Date
    Jul 2011
    Location
    somewhere
    Posts
    37
    Rep Power
    0

    Default What is the difference?

    I was wondering what is the difference between
    Java Code:
    public static void main(String args[])
    and
    Java Code:
    public static void main(String[] args)
    ive seen them both ways and in practice ive seen no difference between the two, but what i want to know is if there is some obscure program that will crash if it is written one way over the other.

  2. #2
    JeffGrigg is offline Member
    Join Date
    Aug 2011
    Posts
    95
    Rep Power
    0

    Default

    They're both the same. There is no difference.

    The second is preferred, as it puts the "array" brackets with the type.

    See:
    Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)

    Also, this will work:
    Java Code:
    public static void main(String... args)
    (And it works just like the other two.)
    sunde887 likes this.

  3. #3
    sublixt's Avatar
    sublixt is offline Member
    Join Date
    Jul 2011
    Location
    somewhere
    Posts
    37
    Rep Power
    0

Similar Threads

  1. what is the difference
    By ron87 in forum New To Java
    Replies: 5
    Last Post: 01-04-2011, 05:31 PM
  2. what the difference?!!
    By Engineer in forum New To Java
    Replies: 14
    Last Post: 08-29-2010, 05:57 PM
  3. What is the difference between
    By arnab321 in forum New To Java
    Replies: 2
    Last Post: 01-19-2009, 05:49 AM
  4. difference
    By nishant in forum New To Java
    Replies: 2
    Last Post: 09-17-2008, 07:04 PM

Posting Permissions

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