Zero basic learning java (2): identifier, java identifier

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.