Identifiers
An identifier is a word that you make up to associate a name with a Java programming element, such as a variable, field, parameter, class, or method.
Here are the rules for creating identifiers:
Identifiers are case-sensitive. As a result, SalesTax
and salesTax
are distinct identifiers.
Identifiers can be made up of uppercase or lowercase letters, numerals, underscore characters (_
), and dollar signs ($
). Thus, you can have identifier names such as Port1
, SalesTax$
, and Total_Sales
.
All identifiers must begin with a letter. Thus, a15
is a valid identifier, but 13Unlucky
isn’t (because it begins with a numeral).
An identifier can’t be the same as any of the Java keywords listed earlier in this part. Thus, you can’t create a variable named for
or a class named public
.
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.