You can also assign a value after declaring it first
Automatic type conversion
1. The target type can be compatible with the source type, such as type double compatible int, but char type cannot be compatible with int
2. The target type is greater than the source type, such as the double type is 8 bytes long, the int type is 4 bytes, so the double type of the variable can directly hold the int type of data, but the reverse is not possible
Forcing type conversions
For example, how do you do this when you need to assign the value of a double variable to a variable of type int?
Obviously, this conversion is not automatic! Because the int type has a smaller storage range than a double type. This is done by forcing type conversions.
Syntax: (data type) values
Constant
The so-called constant, which we can understand as a special variable, whose value is set, is not allowed to change during program operation.
Syntax: final constant name = value;
Comments
In general, for a specification of the program source code, the note should be accounted for more than 1/3 of the source code. Therefore, note is an important part of the program source code, we must pay attention to Oh!
There are three types of annotations in Java: single-line comments, multiline comments, document annotations
Run Result: Hello imooc!
We can use the Javadoc command to extract the content from the documentation comments and generate the program's API help documentation.
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
Variable definitions in Java