Results 1 to 3 of 3
  1. #1
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Rep Power

    Default String[] or args[]

    I am new to programming.

    In the well-known public static void main(xxx), should the arguement of main be String[] args or String args[]?

    I have seen both and don't know which to use.

    What do they actually mean anyway?

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Rep Power

    Default Re: String[] or args[]

    You can use both
    Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
    You can also place the square brackets after the array's name:

    // this form is discouraged
    float anArrayOfFloats[];

    However, convention discourages this form; the brackets identify the array type and should appear with the type designation.

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: String[] or args[]

    I agree with the above quote.
    Java Code:
    int someExtremelyLongVariableName[];
    int[] someExtremelyLongVariableName;
    Glancing at the 2 lines above you can easily see that the second is an array. Whereas for the first line you must cast your eyes all the way to the right to see if it is an array or not. The human brain can be lazy, simply ignore the right hand side and mistake it for an int variable and not an array.

Similar Threads

  1. Why can't we write main without String args[]
    By shailender in forum New To Java
    Replies: 6
    Last Post: 06-17-2013, 09:28 AM
  2. Finding Max and Min values from string args
    By Mortus in forum New To Java
    Replies: 4
    Last Post: 03-22-2012, 03:01 PM
  3. use of String[] args
    By mallikanala in forum New To Java
    Replies: 1
    Last Post: 06-21-2011, 08:09 AM
  4. String, quotes and args
    By mac in forum New To Java
    Replies: 8
    Last Post: 02-04-2010, 04:24 PM
  5. What does String args[] stand for?
    By Addez in forum New To Java
    Replies: 7
    Last Post: 08-19-2009, 10:24 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