Next: 1.4 Java Data Types
Up: 1.3 Java Mechanics
Previous: 1.3.7 Defining Constants
By convention, Java programs are written entirely in lower case
characters with three exceptions.
- The first letter of class names are capitalized to distinguish class
names from member names.
- The names of constant static final
fields are written entirely capital letters.
For example, the static final fields in the preceding
subsection are all capitalized according to this convention.
- The first letter in each word of a multi-word identifier after the first
is capitalized. For example, the built-in Java class Object includes
a method called toString() that we will discuss later. The
capital S signifies the beginning of a word within the multi-word
name toString().
These conventions are not enforced by Java compilers, but it is
considered bad style to violate them. A related convention is to
never use the special character $ in a name; this character is
reserved for the use of the Java compiler. Unfortunately, most Java
compilers do not enforce this convention.
Java relies on commenting conventions similar to those in C++. A
comment that is confined to a single line begins with the character
sequence // and ends at the end of the line. Longer comments
must be enclosed between the opening ``bracket'' /* and
``closing'' bracket */. Examples of both form of comments
appear in Section 1.6. Note that a bracketed comment
can appear in the middle of a line of code.
Finger Exercise 1.3.8.1: add both forms of comment to the Conversions and Person classes from the preceding exercise.
Next: 1.4 Java Data Types
Up: 1.3 Java Mechanics
Previous: 1.3.7 Defining Constants
Corky Cartwright
2002-08-09