Key words:
keywords are identifiers that have special meanings in Java programs. Keywords are typically used to describe the structure of a program or to represent a data type. They are used to represent a data type , or to represent the structure of a program , etc., and the keyword cannot be used as a variable name, method name, class name, package name.
1.1 Common keywords
Note: you do not have to memorize, if you use the keyword as an identifier, the compiler can prompt for errors.
Goto is a reserved keyword for Java, meaning that Java does not use Goto and is later used undecided.
Identifier:
Some of the names in Java programs can be customized, so these custom names are called as custom identifiers.
Identifiers to note the details:
1. The constituent element of the identifier is the letter (a-za-z), the number (0-9), the underscore (_), the dollar sign ($).
2. Identifiers cannot begin with a number.
3. Identifiers are strictly case-sensitive.
4. The length of the identifier is not limited in length.
5. The name of the identifier is generally meaningful (to make people aware of the name, to improve the code of reading)
6. Keywords, reserved words cannot be used for custom identifiers.
Specification for custom identifiers:
1. The first letter of the class name and interface list Word is capitalized, and the other words are lowercase. For example: RunTime.
2. Variable name and method name the first word all lowercase, other words first uppercase, other lowercase. For example: Docook ();
3. Package name all words lowercase.
4. Constant all the words are capitalized, and the words are separated from the words using an underscore. For example: up_direction
Legal identifiers
Computearea,radius,area $itcast, _itcast,gz_itcast
Note: Because Java is strictly case-sensitive, itcast and itcast are completely different identifiers
Illegal identifiers
- Class (keyword)
- 100java (cannot start with a number)
- Hello Java (spaces are not elements that make up identifiers)
Identifier Case:
12ABC_//illegal numbers cannot start
_12ABC//Legal
$ab 12#//illegal #号不属于标识符组成元素.
[Email protected]//Illegal @ does not belong to the identifier component element.
java-Keywords & identifiers