Basic type conversion

In java, basic types can be converted to each other, boolean types are special and cannot be converted to other types.
Conversion is divided into default conversion and forced conversion :.
■ Default conversion: The type with small capacity will be converted to the type with large capacity by default.
◆ byte–> short–> int-> long-> float–> double (max)
char–>
◆ Calculation between byte, short and char will not be converted between each other, first convert to int
forced conversion +
◆ The capacity will be large Type conversion into a type with a small capacity requires a forced conversion.
Note: As long as it does not exceed the range, integer values ​​can be directly assigned to byte, short, char.
In a mixed operation of multiple types, first convert all data to the one with the largest capacity, and then calculate.

Published 43 original articles · praised 2 · visits 1014

Guess you like

Origin blog.csdn.net/study_azhuo/article/details/104572820