Java Reference
In-Depth Information
in cases in which the controlling data is already in string form. In other words, don't use
strings in a switch unnecessarily.
Using Command-Line Arguments
Now that you know about the String class, you can understand the args parameter to
main( ) that has been in every program shown so far. Many programs accept what are
called command-line arguments . A command-line argument is the information that direc-
tly follows the program's name on the command line when it is executed. To access the
command-line arguments inside a Java program is quite easy—they are stored as strings in
the String array passed to main( ) . For example, the following program displays all of the
command-line arguments that it is called with:
If CLDemo is executed like this,
you will see the following output:
Search WWH ::




Custom Search