The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Learning the Java Language
Lesson: Language Basics

Variable Names

A program refers to a variable's value by the variable's name. For example, when it displays the value of the largestByte variable, the MaxVariablesDemo program uses the name largestByte. A name, such as largestByte, that's composed of a single identifier is called a simple name. Simple names are in contrast to qualified names, which a class uses to refer to a member variable that's in another object or class. This topic is covered further in the Using Objects (in the Learning the Java Language trail) section.

In the Java programming language, the following must hold true for a simple name:


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, the words are joined together, and each word after the first begins with an uppercase letter (for example, isVisible). The underscore character ( _ ) is acceptable anywhere in a name, but by convention it is used only to separate words in constants (because constants are all caps by convention and thus cannot be case-delimited).

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.