Java Reference
In-Depth Information
The purpose of this program line is to display the message “Hello
World, this is Java” on the screen. System is a built-in class that is part of
the standard Java libraries, while out is an object of this class. The word
println(), pronounced print line, is a method of the System.out stream.
The purpose of this line is to display a single text line on the video dis-
play. The text to be displayed is contained in double quotes. This is called
a string literal . A stream can be visualized as a sequence of characters
between a source (reader) and a destination (writer).
Figure2-1 showstheelementsofthisprogramline.Theseelementsare
discussed in detail in later chapters.
stream
println() parameters
System.out.println("Hello World,this is Java");
terminator
end of parameters
end of string
string
start of string
start of parameters
method
object
class
Figure 2-1 Breakdown of the println() Statement
At the end of the program listing we see two right-hand rosters. The
first one marks the end of the main() method. The second right-hand ros-
ter marks the end of the class HelloJava, which in this case is also the end
of the program.
Creating the HelloJava Program
As a first programming exercise, you should now type, compile, and run the
HelloJava program. This will also serve to make sure that your develop-
ment system is working correctly. Start by executing the editor of your
choice and typing in the code. Make sure that you maintain the same capi-
talizationasinthelisting. Figure2-2 showstheprogramasitappearsinthe
TextPad editor screen.
 
Search WWH ::




Custom Search