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:

check.png Identifiers are case-sensitive. As a result, SalesTax and salesTax are distinct identifiers.

check.png 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.

check.png All identifiers must begin with a letter. Thus, a15 is a valid identifier, but 13Unlucky isn’t (because it begins with a numeral).

check.png 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.

tip.eps check.png The Java language specification recommends that you avoid using dollar signs in names you create because code ...

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.