The JavaTM Tutorial

| Start of Tutorial > Start of Trail > Start of Lesson | Search

Trail: Learning the Java Language
Lesson: The Nuts and Bolts of the Java Language

## Variable Names

> A program refers to a variable's value by its name. For example, when the `MaxVariables` program displays the value of the `largestByte` variable, it simply uses the name `largestByte`.

> In Java, the following must hold true for a variable name:

> 1. It must be a legal Java identifier comprised of a series of Unicode characters. Unicode is a character-coding system designed to support text written in diverse human languages. It allows for the codification of up to 65,536 characters, currently 34,168 have been assigned. This allows you to use characters in your Java programs from various alphabets, such as Japanese, Greek, Cyrillic, and Hebrew. This is important so that programmers can write code that is meaningful in their native languages.
> 2. It must not be a keyword, a boolean literal (`true` or `false`), or the reserved word `null`.
> 3. It must be unique within its scope.

> > By Convention: Variable names begin with a lowercase letter and class names begin with an uppercase letter. If a variable name consists of more than one word, such as `isVisible`, the words are joined together and each word after the first begins with an uppercase letter.

> Rule #3 implies that variables may have the same name as another variable whose declaration appears in a different scope. This is true. In addition, in some situations, a variable may share names with another variable which is declared in a nested scope. Scope is covered in the next section.

| Start of Tutorial > Start of Trail > Start of Lesson | Search