Java-constants and variables, Java-constant variables
Keywords that have special purposes in Java are called keywords. Keyword service is case sensitive.
An identifier is a symbol used to name variables, classes, and methods in a java program.
Several Rules of the identifier:
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:
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.
Syntax: (data type) Value
Forced type conversion may cause data loss. Use it with caution.
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 ';
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.