Java Reference
In-Depth Information
In the Welcome to My Day program, the argument for the println() method
is the data sent to the monitor at run time. In lines 14 and 18, no argument is
displayed in the parentheses, so a blank line with no text will be displayed. In
line 15, the string of characters enclosed in quotation marks inside the parenthe-
ses will be sent to the monitor for display. The string of characters is called a
literal , which means the data inside the quotes will be displayed exactly as
entered in the code. You will learn how to use the println() method to display
stored String data, as well as literal and stored numeric data. When using the
println() method to output numbers and variables to the display, you do not
need to enclose the argument in quotation marks.
Lines 14 through 18 each end with a semicolon (;). Other than headers and
braces, all lines of Java code must end with a semicolon. Line 15 uses the object-
oriented components of classes, objects, and methods all in one line.
System is the name of the class; out is the object that represents the default dis-
play; and println() is the name of a method that accepts a String argument.
After entering the code to display output, you will close the class and the
main() method by entering the respective closing braces. You then will save the
program. Perform the following steps to enter the code to display output, and
then save the Java program file on the Data Disk in drive A.
To Enter Code to Display Output and Save the Program File
1. With the insertion point in line 14, enter the code as shown in
Figure 2-23, keeping in mind that Java is case-sensitive.
The TextPad window displays the Java source code for the five println()
methods (Figure 2-24). Lines 14 and 18 will cause the program to output
blank lines.
literal
println()
methods
insertion
point
all lines end
with semicolon
FIGURE 2-24
(continued)
 
Search WWH ::




Custom Search