What is keyword?
is endowed with the special meaning of the Java language, and there is a special-purpose string (or word)
Features: all letters are lowercase
What are the key words?
Describe data types
class interface enum
Byte, short, int, long, float, double, char, Boolean
A keyword used to define data type values
true false null
Used to define process control
if, else, switch, case, default
While, do, for, break, continue, return
Defines the keyword for access permission modifiers
private protected public
The keyword used to define classes, functions, variables, modifiers, and so on
abstract final static synchronized
A keyword used to define the relationship between a class and a class
Used to define instances and reference instances, and to determine the keywords of an instance
new this super instanceof
Keywords for exception handling
try, catch, finally, throw, throws
Key for packages
Other modifier keywords
native, strictfp, transient, volatile, assert
Two, reserved words
What is reserved word?
The existing Java version of
is not yet in use, but later versions might be used as keywords.
When we rename identifiers, we should avoid using keywords and avoid using reserved words.
If you now use a reserved word, if which day update becomes the key word, means the old version using the reserved word all must be replaced, quantity is too large, one begins to tell you I will use, occupied, you don't have to use.
Reserved words in Java
byValue, cast, future, generic, inner, operator, outer, rest,, VaR, goto, const...
What is an identifier?
Java specifies the character sequences used for naming various variables, methods, and classes. Identifiers are called identifiers where they can make their names, such as variable names, method names, class names, and interface names, etc.
What is the legal identifier rule? (must follow the rules)
consists of 26 English letters, 0-9, or $_.
Numbers cannot begin
You cannot use keywords and reserved words, but can contain keywords and reserved words
Java is strictly case insensitive and unlimited in length
Identifiers cannot contain spaces
What is the naming standard? ("standard" is not necessary to comply, but the best way, this is a good habit, make the code clean, improve reading ability)
hump nomenclature: XxxYyyy
Package name: when many words are formed, all letters are lowercase, xxxyyyzzz
Class name, interface name: when multiple words are formed, the initial letters of all letters are capitalized, XxxYyyZzz
Variable name, method name: when multiple words are formed, the first word is lowercase, and the second word begins with the initial letter, xxxYyyZzz
Constant names: all letters are capitalized. When many words are used, the word is underlined by the underscore, XXX_YYY_ZZZ