Although the keyword and identifier do not have much to do, but given that these two words often appear together, put together to comb it.
Key words
Defined:
was Java language gives special meanings to 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
C. Keywords used to define Process control
If |
Else |
Switch |
Case |
Default |
While |
Do |
For |
Break |
Continue |
Return |
|
|
|
|
Note: Goto and the Const Although never used, it remains as a reserved word (in JDK may be promoted to a keyword in the new version.
Identifier
Defined:
the user is programmed to give classes, variables / the names of constants, methods (functions), statement blocks, and so on.
Composition rule:
A. by Digital 0-9 , - The case of an English letter , $ and the _ composition;
B. cannot begin with a number ;
C. cannot be a keyword (finally a little bit with the keyword)
D. do not use spaces in the name
E.java Strictly case-sensitive in
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
Summary:
The keywords are defined by the language itself, and the identifiers are named by ourselves, so that we can better understand the program, unify everyone's cognition, and make good communication between programmers, programmers and machines. There are many rules, but they are worth keeping.
Java Basics-Keyword vs identifier