Java Reference
In-Depth Information
soon learn how Java programmers use white space to make the code more
pleasant and readable.
Java uses braces {} as grouping symbols. They mark the beginning and the
end of a program section. A Java program must have an equal number of left
and right braces. The part of a Java program located between braces is
called a block .
Every Java statement ends in the ; symbol. A statement is a program element
that generates a processing action. Not every Java expression is a state-
ment.
Computer programs usually contain text that clarifies or explains the code.
These are called comments . Comments must be preceded by a special sym-
bol so that the text is ignored by the compiler. In Java, there are two ways of
inserting comments into your code:
The // symbol creates a comment that extends to the end of
the line. For example:
// This is a single-line comment
The // symbol can appear anywhere in a program line.
/* and */ symbols are used to delimit a comment that can span over
more than one line, for example:
/* This is a
multiple line
comment */
Programmers note:
Multiple line comments are now considered bad style. The reason is
that comments that span several lines may force the reader to look up
or down in the text for the comment symbols. A much clearer style is
to use the double slash symbol to mark each comment line. This is the
style we follow.
The program header
Programs often begin with several commented lines, sometimes called the
program header , that contain general information about the code that fol-
lows. The following elements are usually found in the program header:
The program name
The name of the author or authors
A copyright notice, if one is appropriate
Search WWH ::




Custom Search