Java (III) conversion between basic types

Automatic type conversion: types with small capacity are automatically converted into data types with large capacity. The data types are sorted by capacity as follows:

Byte, short and char are not converted to each other. They are first converted to int type during calculation;

That is, when declared as the sum of B + C, m must be of type int;

When the value of any basic data type is connected with the string value (+), the value of the basic data type will be automatically converted to the string type;

The output is hello1, and anything enclosed in double quotes is a string type.

When it is necessary to convert a large capacity basic type to a small capacity data type, a forced conversion is required, for example:

Generally, the string type cannot be directly converted to the basic type, but the string can be converted to the basic type through the wrapper class corresponding to the basic type;

It should be noted that the value in the string must be convertible to other basic types.

Boolean types cannot be converted to other underlying data types.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>