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