Java basic-identifiers and naming conventions, and java basic identifiers

Source: Internet
Author: User

Java basic-identifiers and naming conventions, and java basic identifiers

Anything that can be named by yourself is called a modifier.

Example: Project name, package name, class name, Method Name

2.Naming rules.

① Java keywords and reserved words cannot be used, but they can contain keywords and reserved words.

② 26 uppercase/lowercase letters, numbers 0-9, $, and _.

③ Numbers can be used, but cannot be placed first.

④ There is no limit on the length theoretically, but it is best to reflect the effect of the name, follow the "Hump form", see life and wisdom.

Example: Write an ajax project instance,

Project name: ajaxtest

Package name: com. liu. ajax

Class Name: AjaxDemo

3.Usage and specifications of annotations.

In Java development, there are three types of Annotations:

① Single line comment:

// This is a single row commentaries

② Multi-line comment:

/* This is a multi-line comment, used outside the method, prompting the use of the method */

Public void show (){

Code block

}

③ Document notes:

/**

* Document comment

* Author

* Last modification time

*/

When using Eclipse for development, You can automatically generate a template for annotation. The setting steps are as follows:

Windows-Preferences-Java-Code Style-Code Template-Code

    

Notes:

Class Annotation

/**

* FileName: Test. java

* @ Author class creator name
* @ Date creation Date

**/

② Attribute Annotation

/** Attribute function */

Private String afgsd = null

③ Method Annotation

/**

* @ Param parameter 1 Description of parameter 1

* @ Return description of returned results

* @ Throws exception type. The error code indicates the exception thrown from this class method.

*/

 

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.