mentthatreturnsavalueofthistype(e.g., return 0; ),thecompilerwillnot
reportanerror.However,youwon'tbeabletorun HelloWorld becausethe
proper main() method would not exist.
• (String args) :Thisparameterlistconsistsofasingleparameternamed
args oftype String .Startupcodepassesasequenceofcommand-linear-
gumentsto args ,whichmakestheseargumentsavailabletothecodethatex-
ecuteswithin main() .You'lllearnaboutparametersandargumentsin Chapter
The block of code consists of a single System.out.println("Hello,
world!"); methodcall.Fromlefttowrite, System identifiesastandardclassofsys-
tem utilities, out identifies an object variable located in System whose methods let
you output values of various types optionally followed by a newline character to the
standardoutputdevice, println identifiesamethodthatprintsitsargumentfollowed
byanewlinecharactertostandardoutput,and "Hello, world!" isa string (ase-
quenceofcharactersdelimitedbydoublequote " charactersandtreatedasaunit)thatis
passedastheargumentto println andwrittentostandardoutput(thestarting " and
ending " double quote characters are not written; these characters delimit but are not
part of the string).
graphical user interfaces with their controls for inputting and outputting values (e.g.,
textfields), these applications obtained their input and generated their output with the
help of Standard I/O , an input/output mechanism that originated with the Unix oper-
The user would input data via the standard input device (typically the keyboard, but
a file could be specified instead—Unix treats everything as files). The application's
output would appear on the standard output device (typically a computer screen, but
optionally a file or printer). Output messages denoting errors would be output to the
Now that you understand how Listing 1-1 works, you'll want to create this applica-
tion. Complete the following steps to accomplish this task:
1. Copy Listing 1-1 to a file named HelloWorld.java .
2. Execute javac HelloWorld.java tocompilethissourcefile. javac will
complain if you do not specify the “ .java ” file extension.