<< Chapter < Page | Chapter >> Page > |
public
The keyword public indicates that the method can be called by any object. A future module will discuss the keywords public , private , and protected in more detail.
static
The keyword static indicates that the method is a class method, which can be called without the requirement to instantiate an object ofthe class. This is used by the JVM to launch the program by calling the main method of the class identified in the command to start the program.
void
The keyword void indicates that the method doesn't return any value.
args
The formal parameter args is a reference to an array object of type String . The array elements contain references to String objects that encapsulate String representations of the arguments, if any, entered at thecommand line.
Note that the args parameter must be specified whether or not the user is required to enter command-line arguments and whetheror not the code in the program actually makes use of the argument. Also note that the name can be any legal Java identifier. It doesn't have to be args . It could be joe or sue, for example.
The length property
The parameter named args is a reference to an array object. Java array objects have a property named length , which specifies the number of elements in the array.
The runtime system monitors for the entry of command-line arguments by the user and constructs the String array containing those arguments.
Processing command-line arguments
The args.length property can be used by the code in the program to determine the number of arguments actually entered by the user.
If the length property is not equal to zero, the first string in the array corresponds to the first argument entered on the commandline.
Command-line arguments along with strings and String arrays will be discussed in more detail in a future module.
This section contains a variety of miscellaneous information.
Financial : Although the Connexions site makes it possible for you to download a PDF file for thismodule at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should beaware that some of the HTML elements in this module may not translate well into PDF.
I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.
In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. I neither receive compensation for those sales nor do I know who doesreceive compensation. If you purchase such a book, please be aware that it is a copy of a module that is freelyavailable on cnx.org and that it was made and published without my prior knowledge.
Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.
-end-
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?