Like C, the main function can pass in parameters, which are called command line parameters.
In some cases, this parameter is meaningful, for example, in the android source code.
The command line parameters in Java are in the following format:
Main (string [] ARGs)
Alternatively, you can use the array method of class C:
Main (string ARGs [])
Depending on the advantages of the Java array, the length of the parameter array is provided directly, and you do not need to input another parameter like the C language.
Example:
Public class cmd {public static void main (string [] ARGs) {int length = args. length; For (INT I = 0; I <length; ++ I) {system. out. println ("ARGs [" + I + "]" + "is" + ARGs [I]) ;}}
After compiling with javac, directly call thisProgram:
D: \ workspace \ Java> JAVA cmd Liaoning Shenyang hepingargs [0] Is liaoningargs [1] is shenyangargs [2] is Heping