Java 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.
When assigning a value to a char variable, use "when assigning a value to a string variable"
In Java, the default declaration of decimals is double type, such as: Double d=4.0
If the declaration: float x = 4.0 will be an error, you need to use the following notation: float x = 4.0f or float x = (float) 4.0
Where the F behind 4.0f is just to differentiate double, it doesn't mean any number.
Conditions for automatic type conversions:
The target type can be compatible with the source type, for example: Double is compatible with int, but char is incompatible with int
The target type is greater than the source type, such as a double with a length of 8 bytes and an int type of 4 bytes, so a variable of type double can directly hold data of type int, but in turn it cannot be
To force type conversions:
Such as:
double avg1=75.8; int avg2=(int)AVG1; #强制把double转换为int
Casts can cause data loss
Java Data types