The first stage: JAVA Quick Start (Forty-second lesson: JAVA automatic type conversion)

        It refers to a type of automatic conversion small capacity type data can be automatically converted into a large capacity of data types. 2-6, the black line represents the automatic type without loss of data conversion, while the dotted line indicates the conversion accuracy may be lost.

1.png

FIG automatic conversion 2-6

 

        Integer constant can be directly assigned byte, short, char and other types of variables, without the need for cast, as long as the number does not exceed the table range.

[Example 2-26] Specific examples automatic conversion

short  b = 12;  //合法

short  b = 1234567;//非法,1234567超出了short的表数范围

Note: You do not have to remember, to remember large to accommodate small and large houses put a small house things simple! Integer is easy to understand, the more precise floating point, equivalent to the longer length of the house, will put more stuff!

Published 49 original articles · won praise 6 · views 10000 +

Guess you like

Origin blog.csdn.net/ZGL_cyy/article/details/104089137