1. Variables and Constants

Source: Internet
Author: User
Tags java keywords

1 identifiers

Identifiers are symbols that are used to name variables, classes, methods, and so on in a Java program.

1>. Identifiers can consist of letters, numbers, underscores (_), dollar symbols ($), but cannot contain other special characters, such as @,%, space, and cannot begin with a number. For example: 123name is not legal drop

2>. Identifiers cannot be Java keywords and reserved words (Java reserved keywords, which may be keywords in later versions of the upgrade), but can contain keywords and reserved words. For example, void may not be used as an identifier, but myvoid can

3>. Identifiers are strictly case-sensitive. So nirvana, be sure to distinguish between Chu Imooc and Imooc is two different identifiers Oh!


2 data Types The Java language is a strongly typed language. The popular point is that the data stored in Java is typed and must be determined at compile time. There are two kinds of data types in Java:


String is a common reference data type that is used to represent a string.

Float type variable, whose decimal value is followed by F, and double does not


3 Automatic type conversion

The 1> target type can be compatible with the source type, such as double compatible int, but char type is not compatible with int

The 2> target type is greater than the source type, such as a double type of 8 bytes and an int type of 4 bytes, so a variable of type double can directly hold data of type int, but not vice versa.


4 constant declarations

Syntax: final constant name = value;

Note: Constant names generally use uppercase characters


5 Notes

There are three types of annotations in Java: single-line comments, multiline comments, document annotations

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

@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


1. Variables and Constants

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.