Keywords, reserved words, and identifiers for the JAVA foundation
May 30, 2021
Article blog
Table of contents
keywords:
1. Definition and characteristics of keywords
-
Definition: A string (word) that has been given a special meaning by the Java language for specialized purposes
-
Features: All letters in the keyword are lowercase
-
Official address:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
The keyword used to define the data type
|
|
|
|
|
class
|
interface
|
enum
|
byte
|
short
|
int
|
long
|
float
|
double
|
char
|
boolean
|
void
|
|
|
|
Keywords used to define process control
|
|
|
|
|
if
|
else
|
switch
|
case
|
default
|
while
|
do
|
for
|
break
|
continue
|
return
|
|
|
|
|
The keyword used to define the access modifier
|
|
|
|
|
private
|
protected
|
public
|
|
|
Keywords used to define classes, functions, and variable modifiers
|
|
|
|
|
abstract
|
final
|
static
|
synchronized
|
|
Keywords that define the relationship between a class and a class
|
|
|
|
|
extends
|
implements
|
|
|
|
Used to define the keywords for establishing and referencing instances and judging instances
|
|
|
|
|
new
|
this
|
super
|
instanceof
|
|
The keyword used for exception handling
|
|
|
|
|
try
|
catch
|
finally
|
throw
|
throws
|
The keyword used for the package
|
|
|
|
|
package
|
import
|
|
|
|
Other modifier keywords
|
|
|
|
|
native
|
strictfp
|
transient
|
volatile
|
assert
|
The literal value used to define the value of the data type
|
|
|
|
|
true
|
false
|
null
|
|
|
2. Reserved word
-
Java Reserved Word: The existing Java version is not yet in use, but future versions may be used as keywords.
Avoid using these reserved words when you name identifiers yourself.
-
goto 、const.
3. Identifier
identifier:
-
The sequence of characters used by Java when naming features such as variables, methods, and classes is called identifiers.
-
Tip: Anywhere you can name yourself is called an identifier.
Define legal identifier rules:
-
Consisting of 26 English letters in case, 0-9, or $
-
Numbers cannot begin.
-
You can't use keywords and reserved words, but you can include keywords and reserved words.
-
Case sensitive and unlimited length in Java.
-
Identifiers cannot contain spaces.
Naming specifications in Java:
-
Package name:
All letters are lowercase when composed of multiple words: xxxyyyzzz
-
Class name, interface name:
When a multi-word composition, the initials of all words are capitalized: XxxYyyZzz
-
Variable name, method name:
When a multi-word composition, the first word is lowercase, and the second word begins with the capital of each word: xxxYyyZzz
-
Constant name:
All letters are capitalized.
Each word is underlined when multiple words are connected: XXX_YYY_ZZZ
-
Note 1:
When starting a name, in order to improve reading, try to be as meaningful as possible, "see the name."
-
Note 2:
Java uses a unicode character set, so identifiers can also be declared in Chinese characters, but are not recommended.