It is how you access the arguments passed to your program from the java command.
"java MyProgram alpha beta gamma" will pass your MyProgram.main() method a 3 element array of strings looking like this: String[] args = { "alpha", "beta", "gamma" };
A String array is the argument type to the main method used as a Java entry point:
public static void main(String[] args){ ... }
Any legal identifier can be used for this array, although "args" or "argv" are probably the most common (for "arguments" and "argument values" respectively).
The general purpose of this array is a means to pass initial information into a program. When running from the Command Line, arguments can be added after the file name, separated by spaces. For example, "c:\>java FileName Zero One" will invoke the main method of FileName.class, with "Zero" and "One" as elements of the String array passed to that method.
Try compiling the following code, then run with the following commands:
java MainArgs
java MainArgs what is this
Note that args (or whatever you might call it) is like any other argument, in that the reference to the String array is local to the main method; so it's legal (although not advisable) to define another String[] called "args" elsewhere in the class. Also note that a main method can be called like any other method -- it is not restricted to being invoked from the Command Line. [ January 03, 2005: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
What's brown and sticky? ... a stick. Or a tiny ad.
a bit of art, as a gift, that will fit in a stocking