Skip to main content
Lesson 3 - Data Types in Java
Lesson MenuPreviousNext
  
Identifiers in Java page 3 of 11

  1. An identifier is a name that will be used to describe classes, methods, constants, variables, and other items.

    1. Identifiers must begin with a letter.
    2. Only letters, digits, or underscore may follow the initial letter.
    3. The blank space cannot be used.
    4. Identifiers cannot be reserved words. Reserved words or keywords are only for system use.

  2. Java is a case sensitive language. That is, Java will distinguish between upper and lower case letters in identifiers. Therefore:

    grade and Grade are different identifiers
  3. A good identifier should help describe the nature or purpose of that function or variable. It is better to use

    grade instead of g, number instead of n.
  4. However, avoid excessively long or "cute" identifiers such as:

    gradePointAverage or bigHugeUglyNumber

    Remember that our goal is to write code that is easy to read and professional in nature.

  5. Programmers will adopt different styles of using upper and lower case letters in writing identifiers. The reserved keywords in Java must be typed in lower case text, but identifiers can be typed using any combination of upper and lower case letters.

  6. The following conventions will be used throughout the curriculum guide:

    1. A single word identifier will be written in lower case only. Examples: grade, number, sum.
    2. If an identifier is made up of several words, the first letter will be lower case. Subsequent words will begin with upper case. Some examples are: stringType, passingScore, largestNum.
    3. Identifiers used as constants will be fully capitalized. Examples: PI, MAXSTRLEN.


Lesson MenuPreviousNext
Contact
 ©ICT 2003, All Rights Reserved.