An identifier is a name that will be used to describe classes, methods, constants, variables; anything a programmer is required to define.
The rules for naming identifiers in Java are:
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
Be careful both when naming identifiers and when typing them into the code. Be consistent and don’t use both upper and lower case names for the same identifier.
A good identifier should help describe the nature or purpose of whatever it is naming. For a variable name, it is better to use grade
instead of g
, number
instead of n
.
However, avoid excessively long or "cute" identifiers such as:
- gradePointAverageForStudentsAToZ
- or bigHugeUglyNumberThatIsPrettyPointlessButINeedItAnyway
Remember that the goal is to write code that is professional in nature; other programmers need to understand your code.
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.
The following conventions will be used throughout this curriculum guide:
grade
, number
, sum
.
String
, DrawingTool
, SketchPad
, Benzene
.stringType
, passingScore
, largestNum
, DrawHouse
, SketchPad
.PI
, MAXSTRLEN
.Last modified: December 12, 2022