Identifiers are the names you give to variables, methods, classes, interfaces, and enumerations. Unlike literals, identifiers only help you reference something.
The program shown in the first example
uses seven identifiers.
* Hello
* main
* String
* arguments
* System
* out
* println
ArrayList
with uppercase a and arrayList
with lowercase a are two different identifiers._
, and dollar symbols $
.f07
is a valid
identifier, but 7feb
isn’t. Because it begins with a numeral.double
isn’t a valid
identifier.Here’s an example of valid identifiers.
helloWorld
__student
Object
STRING
invoke123
$person
i
x1010
Here’s an example of invalid identifiers.
void /* void is a keyword. You can't use a keyword as an identifier. */
hello world /* An identifier can't have spaces. */
3dCube /* An identifier can't begin with a numeral. */
a*a /* An identifier can't have symbols. */