Introduction to Java Basic semantics

Source: Internet
Author: User

1. Identifiers

Identifiers can consist of letters, numbers, underscores (_), dollar sign ($), but cannot contain other special characters, such as @,%, space, and cannot begin with a number.

Identifiers cannot be Java keywords and reserved words (Java reserved keywords, which may be keywords in future upgrades), but can contain keywords and reserved words.

Identifiers are strictly case-sensitive.

The name of the identifier best reflects its role, to be known.

2. Variable definition

Variable type variable name = variable value;

String Value = "This is a Value";

3. Data type

In the Java domain, the basic data type variable is stored in the data itself, whereas the reference type variable holds the spatial address of the saved data.

To put it bluntly, the basic data type variables are stored directly in the drawer, while the reference data type variable stores the key to the drawer, and the key and drawer one by one correspond.

The common basic data types are:

Note: strings are enclosed in double quotation marks, and the characters are enclosed in single quotation marks .

Java can be declared and initialized at the same time

3. Forcing type conversions

Double Source1 = 66.6;

In Value = (int) Source; 66

4. Constant final

Final String VALUE = "This is a Final";

Final double PI = 3.14;

Note: constant names generally use uppercase

5. Notes

Single-line Comment:

Here is the comment information

Multi-line Comments:

/*

* Here is the comment information

* Here is the comment information

*/

Documentation notes:

/**

* @author Redbutterfly

* @version v1.0

*/

You can also use the Javadoc tag to generate more detailed document information when working with document annotations:

@author identify the author of the development of such modules

@version indicate the version of the module

@see reference steering, i.e. related topics

@param a description of a parameter in the method

@return Description of the return value of the method

@exception description of the exceptions that the method might throw

Introduction to Java Basic semantics

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.