Java-constants and variables, Java-constant variables

Source: Internet
Author: User

Java-constants and variables, Java-constant variables

  • Keywords

Keywords that have special purposes in Java are called keywords. Keyword service is case sensitive.

  

  • Identifier

An identifier is a symbol used to name variables, classes, and methods in a java program.

Several Rules of the identifier:

  • Variable

Three elements are used to describe variables: variable type, variable name, and variable value.

Naming rules for variables: camper name, known and case sensitive, such as myAge and stuName.

Usage rules of variables:

  • Data Type

Java is a strongly typed language and its type must be determined during compilation.

  

The basic data type stores the data itself, and the referenced data type stores the space address of the stored data.

  

When a float variable is assigned a value, add the letter f after the value.

Single quotation marks (') are used to assign values to char variables. Double quotation marks (") are used to assign values to String variables, for example, Sting name =" Zhang San "; Char sex = 'male ';

  • Automatic type conversion
int score1 = 82;double score2 = score1;System.out.println(score2);

Running result: 82.0

Condition: the target type is compatible with the source type. For example, the double type is compatible with the int type, but the char type is not compatible with the int type. The target type is greater than the source type. For example, the double type can be used to store the int type, but in turn it cannot.

  • Forced type conversion

Syntax: (data type) Value

Forced type conversion may cause data loss. Use it with caution.

  • Constant

A constant is a special variable. After its value is set, it cannot be changed during the running of the program. It is generally written in uppercase.

Syntax: final constant name = value; for example, final String LOVE = 'java ';

  • Note

  

  

You can also useJavadoc flagTo generate more detailed document information:

@ Author indicates the author of The development class module

@ Version indicates the version of the module.

@ See references, that is, related topics

@ Param description of a parameter in the other method

@ Return description of the return value of the Method

@ Exception describes possible exceptions thrown by methods.

 

You can use the javadoc command to extract content from the document comments and generate the program's API documentation,

D: \ javaProgram> javadoc-d doc Hello. java is loading source file Hello. java... constructing Javadoc information... creating the target directory: "doc \" Standard Doclet version 1.8.0 _ 65. Building the tree for all packages and classes... generating doc \ Hello.html... generating doc \ package-frame.html... generating doc \ package-summary.html... generating doc \ package-tree.html... generating doc \ constant-values.html... building indexes for all packages and classes... generating doc \ overview-tree.html... generating doc \ index-all.html... generating doc \ deprecated-list.html... constructing indexes for all classes... generating doc \ allclasses-frame.html... generating doc \ allclasses-noframe.html... generating doc \ index.html... generating doc \ help-doc.html...

Open the homepage in a browser, such as file: // D:/javaProgram/doc/index.html.

  

 

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.