An identifier is a name given to a package, class, interface, method, or variable. It allows a programmer to refer to the item from other places in the program. To make the most out of the identifiers you choose make them meaningful and follow the standard Java naming conventions.
Three things to remember when choosing an identifier:
- reserved words cannot be used.
- they cannot start with a digit but digits can be used after the first character (e.g., name1, n2ame are valid).
- the only symbols you can use are the underscore (i.e., "_") and dollar sign (i.e., "$").
If you have variables that hold the name, height and weight of a person then choose identifiers that make their purpose obvious:
String name = "Homer Jay Simpson"; int weight = 300; double height = 6; System.out.printf("My name is %s, my height is %.0f foot and my weight is %d pounds. D'oh!%n", name, height, weight);