Information Technology Reference
In-Depth Information
Identifiers and Keywords
Identifiers are character strings used to name things such as variables, methods, parameters,
and a host of other programming constructs that will be covered later.
You can create self-documenting identifiers by concatenating meaningful words into a
single descriptive name, using uppercase and lowercase letters (e.g., CardDeck , PlayersHand ,
FirstName , SocSecurityNum ). Certain characters are allowed or disallowed at certain positions
in an identifier. These rules are illustrated in Figure 2-2.
The alphabetic and underscore characters ( a through z , A through Z , and _ ) are allowed
at any position.
￿
￿
Digits are not allowed in the first position, but are allowed everywhere else.
￿The @ character is allowed in the first position of an identifier, but not anywhere else. The
use of the @ character, although allowed, is discouraged for general use.
Figure 2-2. Characters allowed in identifiers
Identifiers are case sensitive. For instance, the variable names myVar and MyVar are differ-
ent identifiers. It is generally a bad idea, however, to have identifiers that differ only in the case
of some of the letters.
As an example, in the following code snippet, the variable declarations are all valid and
declare different integer variables. But using such similar names will make coding more error-
prone and debugging more difficult. Those debugging your code at some later time will not be
pleased.
// Valid syntactically, but don't do this!
int totalCycleCount;
int TotalCycleCount;
int TotalcycleCount;
Search WWH ::




Custom Search