November 2006
Intermediate to advanced
224 pages
3h 29m
English
java my_program arg1 arg2 arg3 public static void main(String[] args) { String arg1 = args[0]; String arg2 = args[1]; String arg3 = args[2]; } |
In this phrase, we store the values of three command line arguments into three separate string variables, arg1, arg2, and arg3.
Any java class can have a main() method, which is executable from the command line. The main() method accepts a String array of command-line arguments. The arguments are contained in the array in the order in which they are entered at the command line. So, to retrieve the command-line arguments, you simply have to extract the elements of the arguments array passed into the main() method.
If your application uses a lot of command-line arguments, ...
Read now
Unlock full access