Java variable naming rules

Source: Internet
Author: User
Tags naming convention

Java variable naming convention]

 

Java is a case-sensitive language that distinguishes letters. The following describes the naming rules for packages, classes, and variables in Java.
(1)Package)Name: the package name isA lowercase wordFor example, net. ebseries. modules.
(2)Class)Class NameUppercase letters, UsuallyMerge multiple wordsA class name, requiredThe first letter of each word must be capitalized.For example, datafile or infoparser.

(3)VariableNaming: variable names can be case-insensitive,The first character must be in lower case.. WordUppercase letters are separated, and only underlines are allowed. dollar signs ($) are allowed ),This character has a special meaning for the internal class. For example, inputfilesize.

(4)Interface)Name:Similar to class naming.

(5) Static final variable(Equivalent to a constant) Name: the name of the static final variable should beCapitalAndComplete descriptionFor example, final maxuploadfilesize = 1024.

(6)MethodName: the first word of the method name should beVerb, Case can be mixed,Lowercase letters. In each method name, uppercase letters separate words and limit the use of underscores. The parameter name must be consistent with the variable naming rules. Use meaningful parameter names. If possible, use the same name as the field to be assigned values:
Setcounter (INT size ){
This. size = size;
}
ArrayThe array should always be named in the following way: byte [] buffer; instead of byte buffer [] (habitual problem ).
It is worth noting that the full English descriptor should be used whenever possible (there are also special cases ). In addition, lowercase letters are generally used, but the class name, interface name, and the first letter of any non-initial word must be capitalized. The following points are summarized as follows: Try to use a complete English descriptor, use terminology applicable to relevant fields, use a mix of uppercase and lowercase to make the name readable, and use as few abbreviations as possible, it is wise to use it, unify it throughout the project, avoid using long names (less than 15 letters is a good idea), and avoid using similar names, alternatively, you can only use different names in case and avoid using underscores (except static constants ).

 

 

Java is a case-sensitive language that distinguishes letters. The following describes the naming rules for packages, classes, and variables in Java.
(1)Package)Name: the package name isA lowercase wordFor example, net. ebseries. modules.
(2)Class)Class NameUppercase letters, UsuallyMerge multiple wordsA class name, requiredThe first letter of each word must be capitalized.For example, datafile or infoparser.

(3)VariableNaming: variable names can be case-insensitive,The first character must be in lower case.. WordUppercase letters are separated, and only underlines are allowed. dollar signs ($) are allowed ),This character has a special meaning for the internal class. For example, inputfilesize.

(4)Interface)Name:Similar to class naming.

(5) Static final variable(Equivalent to a constant) Name: the name of the static final variable should beCapitalAndComplete descriptionFor example, final maxuploadfilesize = 1024.

(6)MethodName: the first word of the method name should beVerb, Case can be mixed,Lowercase letters. In each method name, uppercase letters separate words and limit the use of underscores. The parameter name must be consistent with the variable naming rules. Use meaningful parameter names. If possible, use the same name as the field to be assigned values:
Setcounter (INT size ){
This. size = size;
}
ArrayThe array should always be named in the following way: byte [] buffer; instead of byte buffer [] (habitual problem ).
It is worth noting that the full English descriptor should be used whenever possible (there are also special cases ). In addition, lowercase letters are generally used, but the class name, interface name, and the first letter of any non-initial word must be capitalized. The following points are summarized as follows: Try to use a complete English descriptor, use terminology applicable to relevant fields, use a mix of uppercase and lowercase to make the name readable, and use as few abbreviations as possible, it is wise to use it, unify it throughout the project, avoid using long names (less than 15 letters is a good idea), and avoid using similar names, alternatively, you can only use different names in case and avoid using underscores (except static constants ).

Java is a case-sensitive language that distinguishes letters. The following describes the naming rules for packages, classes, and variables in Java.
(1)Package)Name: the package name isA lowercase wordFor example, net. ebseries. modules.
(2)Class)Class NameUppercase letters, UsuallyMerge multiple wordsA class name, requiredThe first letter of each word must be capitalized.For example, datafile or infoparser.

(3)VariableNaming: variable names can be case-insensitive,The first character must be in lower case.. WordUppercase letters are separated, and only underlines are allowed. dollar signs ($) are allowed ),This character has a special meaning for the internal class. For example, inputfilesize.

(4)Interface)Name:Similar to class naming.

(5) Static final variable(Equivalent to a constant) Name: the name of the static final variable should beCapitalAndComplete descriptionFor example, final maxuploadfilesize = 1024.

(6)MethodName: the first word of the method name should beVerb, Case can be mixed,Lowercase letters. In each method name, uppercase letters separate words and limit the use of underscores. The parameter name must be consistent with the variable naming rules. Use meaningful parameter names. If possible, use the same name as the field to be assigned values:
Setcounter (INT size ){
This. size = size;
}
ArrayThe array should always be named in the following way: byte [] buffer; instead of byte buffer [] (habitual problem ).
It is worth noting that the full English descriptor should be used whenever possible (there are also special cases ). In addition, lowercase letters are generally used, but the class name, interface name, and the first letter of any non-initial word must be capitalized. The following points are summarized as follows: Try to use a complete English descriptor, use terminology applicable to relevant fields, use a mix of uppercase and lowercase to make the name readable, and use as few abbreviations as possible, it is wise to use it, unify it throughout the project, avoid using long names (less than 15 letters is a good idea), and avoid using similar names, alternatively, you can only use different names in case and avoid using underscores (except static constants ).

Java is a case-sensitive language that distinguishes letters. The following describes the naming rules for packages, classes, and variables in Java.
(1) package name: the package name should be composed of lowercase words, such as net. ebseries. modules.
(2) Class Name: the first letter of the class name is capitalized. Generally, a class name is composed of multiple words, and the first letter of each word must also be capitalized. For example: datafile or infoparser.

(3) variable naming: The names of variables can be case-insensitive, but the first character must be lowercase. Words are separated by upper-case letters and must contain underscores (_) and dollar signs ($). This character has special meanings for internal classes. For example, inputfilesize.

(4) interface naming: similar to class naming.

(5) name of the static final variable (equivalent to a constant): The names of the static final variables should be capitalized and indicate the complete meaning, for example, final maxuploadfilesize = 1024.

(6) method naming: the first word of the method name should be a verb. The upper and lower cases can be mixed, but the first letter should be in lower case. In each method name, uppercase letters separate words and limit the use of underscores. The parameter name must be consistent with the variable naming rules. Use meaningful parameter names. If possible, use the same name as the field to be assigned values:
Setcounter (INT size ){
This. size = size;
}
Array naming: the array should always be named in the following way: byte [] buffer; instead of byte buffer [] (habitual problem ).
It is worth noting that the full English descriptor should be used whenever possible (there are also special cases ). In addition, lowercase letters are generally used, but the class name, interface name, and the first letter of any non-initial word must be capitalized. The following points are summarized as follows: Try to use a complete English descriptor, use terminology applicable to relevant fields, use a mix of uppercase and lowercase to make the name readable, and use as few abbreviations as possible, it is wise to use it, unify it throughout the project, avoid using long names (less than 15 letters is a good idea), and avoid using similar names, alternatively, you can only use different names in case and avoid using underscores (except static constants ).
 

Related Article

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.