Zero basic learning java (2): identifier, java identifier
1. identifier:
(1) The character sequence used by Java to name various variables, methods, classes, and other elements is called an identifier.
(2) Any place where you can name yourself is an identifier.
Ii. Defining rules for legal identifiers:
(1) It consists of 26 English letters (uppercase and lowercase), 0-9, _ or $.
(2) numbers cannot start.
(3) keywords and reserved words cannot be used, but they can contain keywords and reserved words.
(4) strictly case sensitive and unlimited length in Java
(5) The identifier cannot contain spaces
Note: When naming, to improve readability, we should try to make sense.
Iii. Naming rules in Java
(1) package name: when multiple words are made up, all letters are in lowercase: xxxyyyzzz
(2) Class Name and Interface Name: when multiple words are combined, the first letter of all words is capitalized: XxxYyyZzz
(3) variable name and method name: when multiple words are made up, the first letter of the first word is lowercase, and the second word starts with the first letter of each word: xxxYyyZzz
(4) constant name: All letters are capitalized. When multiple words are used, each word is connected by an underscore: XXX_YYY_ZZZ
Iv. cases:
Identifier: Any place that can be named by yourself is called an identifier. For example, class name, method name, variable name, and interface name ,...
1. Naming rules for identifiers: (strict compliance is required; otherwise, compilation errors will be reported)
It consists of 26 English letters (uppercase and lowercase), 0-9, _, or $.
It cannot start with a number.
Keywords and reserved words cannot be used, but they can contain keywords and reserved words.
Java is case sensitive and has unlimited length.
The identifier cannot contain spaces.
2. Naming Conventions in Java: (if not observed, no error will be reported)
Package name: when multiple words are made up, all letters are in lowercase: xxxyyyzzz
Class Name and Interface Name: when multiple words are made up, the first letter of all words is capitalized: XxxYyyZzz
Variable name and method name: when multiple words are made up, the first letter of the first word is lowercase, and the second word starts with the first letter of each word: xxxYyyZzz
Constant name: All letters are capitalized. When multiple words are used, each word is connected by an underscore: XXX_YYY_ZZZ
*/
ClassTestMarker
{
PublicstaticvoidMain (String [] args)
{
IntStatic1 = 1;
IntMyInt = 12;
System. out. println ("Hello World! ");
}
PublicvoidAdd (){
}
// Note: when naming a name, you should make it as meaningful as possible to improve readability ".
PublicvoidM1 (){}
PublicvoidM2 (){}
}
// Class 4 Hello
ClassStatic {
}
Shang xuexiang opens the door to java and adds No. 858568103. For more information, please wait.