Java keywords and identifiers
First, Java keywords
- 1. Java keyword definition
Java's keywords have special meanings for Java compilers, which are used to represent a data type, or to represent the structure of a program, and the keyword cannot be used as a variable name, method name, class name, package name, or parameter.
- 2. features of the Java keyword
All letters in the keyword are lowercase.
- 3. Java keyword classification
- Keywords to define the data type
class interface byte short int long float
Double char Boolean void
- Keywords to define data type values
True false null
- Keywords to define Process Control
If else switch case default while
Do for break continue return
- Keywords used to define access rights modifiers
Private protected public
- Keywords for defining classes, functions, variable modifiers
Abstract final static synchronized
- Because the keyword that defines the relationship between a class and a class
Extends implements
- Used to define instance and reference instances, and to determine the keywords
New This super instanceof
- Keywords for exception handling
Try Catch finally throw throws
Package Import
Native STRICTFP transient volatile assert
Note:while const and Goto do not have specific meanings in Java, Java also lists them as keywords because const and goto are keywords for some other computer languages.
Second, Java identifiers
- 1. Java identifier definition
Some names that you customize in your program, which contain the class name, package name, method, variable name, and field.
- 2. naming rules for Java identifiers:
- identifiers cannot be keywords;
- Identifiers can contain letters, numbers 0-9, underscores (_), or dollar signs ($);
- The first character of an identifier cannot be a number;
- The identifiers are strictly case-sensitive, and the hump naming method is used;
remark: when naming, improve reading, try to make sense
- 3. the name specification in Java:
- Package Name: When multiple words are composed, all letters are lowercase;
such as: xxxyyyzzz
- Class name and Interface name: When multiple words are composed, the first letter of all words is capitalized;
such as: xxxyyyzzz
- Variable name and function name: When multiple words are composed, the first letter is lowercase, and the first letter of each word begins with the second word capitalized;
such as: xxxyyyzzz
- Constant name: All letters are capitalized. For multiple words, each word is connected with an underscore.
such as: xxx_yyy_zzz
Java keywords and identifiers