Identifier:
1. Identifiers can consist of letters, numbers, underscores (_), dollar symbols ($), but cannot contain other special characters, such as @,%, space, etc., and cannot begin with a number.
2. Identifiers cannot be Java keywords and reserved words (Java reserved keywords, which may be used as keywords in later versions of the upgrade), but can contain keywords and reserved words. For example, void may not be used as an identifier, but myvoid can
3. Identifiers are strictly case-sensitive and do not use spaces in names.
4. The name of the identifier should best reflect its role, to be known.
Common Naming conventions:
A: Package
Used to place files of the same name in different directories.
All lowercase. If it is a multi-level package, use. Separate.
Example: Itcast,cn.itcast, Com.baidu
Project to the company: domain name anti-write as the package name.
B: Classes and interfaces (see name, hump name)
A: Capitalize the first letter of a word.
Example: Student,teacher
B: Consists of multiple words, capitalized on the first letter of each word.
Example: HelloWorld, Haoguibao
C: Methods and variables
A: The first letter of a word is lowercase.
Example: Main (), age
B: If you have multiple words, start with a second word and capitalize the first letter of each word.
Example: ShowName (), Studentage
D: constant
A: If it is a word, all uppercase.
Example: PI
B: If it is multiple words, all uppercase and separated by _
Example: Student_max_age
Key words:
Characteristics:
All letters are lowercase. (a color is shown in many programming software)
Category list:
A. Keywords used to define data types
Class
Interface
Byte
Short
Int
Long
Float
Double
Char
Boolean
void
B. Keywords used to define data type values
True
False
Null
C. Keywords used to define Process control
If
Else
Switch
Case
Default
While
Do
For
Break
Continue
Return
Note: Goto and const are still present as reserved words (which may be promoted to keywords in the new version of the JDK), although they have never been used.
01-java Identifiers and Keywords