2.1 The Elements of Java Programs | 45
Let’s look at an example. This template defines a Java identifier, which is Java’s way of
naming something in a program:
The shading indicates the optional part of the definition. The three dots (... ) mean that
the preceding symbol or shaded block can be repeated. Thus an identifier in Java is a letter,
an underscore, or dollar sign that may be optionally followed by one or more letters, digits,
underscores, or dollar signs.
Remember that a word not in color can be replaced with another template. Consider the
templates for a letter and a digit:
In these templates, the brackets again indicate lists of items from which you can choose
any one. Thus a letter can be any one of the uppercase or lowercase letters, and a digit can
be any of the numeric characters 0 through 9.
Letter
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
Digit
0 1 2 3 4 5 6 7 8 9
Letter
_
$
_...
$
Letter
Digit