Java Reference
In-Depth Information
er is an array of String objects, referred to by the name args . Arrays
of objects are denoted by the square brackets [] that follow the type
name. In this case args will contain the program's arguments from the
command line with which it was invoked. Arrays and strings are covered
later in this chapter. The meaning of args for the main method is de-
scribed in Chapter 2 on page 73 .
The name of a method together with its parameter list constitute the
signature of the method. The signature and any modifiers (such as pub-
lic and static ), the return type, and exception throws list (covered later
in this chapter) form the method header. A method declaration consists
of the method header followed by the method body a block of statements
appearing between curly braces.
In this example, the body of main contains a single statement that in-
vokes the println methodthe semicolon ends the statement. A method
is invoked by supplying an object reference (in this case System.out the
out field of the System class) and a method name ( println ) separated by
a dot ( . ).
HelloWorld uses the out object's println method to print a newline-ter-
minated string on the standard output stream. The string printed is the
string literal "Hello,world" , which is passed as an argument to println . A
string literal is a sequence of characters contained within double-quotes
" and " .
Exercise 1.1 : Enter, compile, and run HelloWorld on your system.
Exercise 1.2 : Try changing parts of HelloWorld and see what errors you
might get.
 
Search WWH ::




Custom Search