The Boolean type cannot be converted to his data type.
The precedence of byte (8-bit), short (16-bit), char three types in Java is the same, and the same priority is not automatic (if you convert to one, you must force type conversions ), only low types are automatically converted to high types, for example, You can convert a byte to an int type automatically. (char is 2 bytes in Java.) Java uses unicode,2 bytes (16 bits) to represent one character. When you assign data of type char to a high-priority type, the type conversion is automatic and the Unicode encoding of the char is assigned to a variable of the high-priority type.
Integer, character, and floating-point data are converted to each other in a mixed operation, which follows the following principles:
Types with small capacity are automatically converted to large data types; The data types are sorted by capacity size:
1, Byte,short,char-->int (32-bit) - Long (64-bit) - Float (32-bit) - double (64-bit)
Byte,short,char do not convert to each other, they are mixed with other data types when the calculation is first converted to int type
2, the large capacity of the data type converted to a small capacity data type, to add a forced conversion, but may result in reduced precision or overflow;
3, there are many types of data blending operations, the system first automatically converts all data to the largest capacity of the data type, and then the calculation.
4, Real constants (such as: 1.2) default to Double.
5, integer constants (such as: 123) default to int.
# # # #值得注意的是:
the equivalence between values is essentially compared to whether their binary storage is equal. For example: 0.3f==0.3 returns False (32-bit 2-binary 0.3 representation and 64-bit 0.3 representation is different); but 0.5f==0.5 returns True (because the binary representation of 32 and 64 bits is the same)
Data type conversion issues in Java