Java Reference
In-Depth Information
Because this fourth statement is a
println
command, it finishes the output line
and positions the cursor at the beginning of the second line. The next statement is
another
print
that produces this:
To be or not to be.That is the question.
This is
^
The final
println
completes the second line and positions the output cursor at the
beginning of a new line:
To be or not to be.That is the question.
This is for the whole family!
^
These six statements are equivalent to the following two single statements:
System.out.println("To be or not to be.That is the question.");
System.out.println("This is for the whole family!");
Using the
print
and
println
commands together to produce lines like these may
seem a bit silly, but you will see that there are more interesting applications of
print
in the next chapter.
Remember that it is possible to have an empty
println
command:
System.out.println();
Because there is nothing inside the parentheses to be written to the output line, this
command positions the output cursor at the beginning of the next line. If there are
print
commands before this empty
println
, it finishes out the line made by those
print
commands. If there are no previous
print
commands, it produces a blank
line. An empty
print
command is meaningless and illegal.
The words used to name parts of a Java program are called
identifiers.
Identifier
A name given to an entity in a program, such as a class or method.
Identifiers must start with a letter, which can be followed by any number of letters
or digits. The following are all legal identifiers:
first
hiThere
numStudents
TwoBy4
Search WWH ::
Custom Search