Identifier
-
Identifier
The character sequence used in java to name various variables, methods and classes is called identifier
-
Define legal identifier rules:
It consists of 26 uppercase and lowercase letters, 0-9, _ or $
Numbers cannot begin with, and keywords and reserved words cannot be used as identifiers, but they can contain keywords and reserved words.intt
Java is strictly case sensitive, and the length is unlimited. A a
The identifier cannot contain spaces.
Note: In order to improve readability, the name should be as meaningful as possible.
-
Naming conventions in Java:
Package name: Multi-words and all letters are lowercase: xxxyyyzzz
Class name, interface name: When multiple words are formed, the first letter of all words is capitalized: XxxYyyZzz
Variable name, method name: When multiple words are formed, the first letter of the first word is lowercase, and the following words are uppercase xxxYyyZzz
Constant name: All letters are capitalized. When there are multiple words, each word is connected with an underscore: XXX_YYY_ZZZ
java variables
Variables are the most basic storage unit in the program, and the values in the execution program are variable
In essence, a variable is actually a small area in memory. The variable name is used to access this area. Therefore, each variable must be declared before it is used, and then must be assigned and executed before it can be used.
Variables access this area by using variable names.
Its elements include variable name and variable type.
Every variable in a Java program belongs to a specific data type and must be declared before use. The declaration format is:
int i = 100;