2018-04-11
Basic Data type Conversions
I. Data too large and overflow
Overflow: Data exceeds critical range of data type
If the overflow occurs, the program does not do the data check range processing, there will be data turbulence (WEN) chaos
Second, the basic data type automatic conversion (implicit conversion)
In eight basic types, Boolean is not a numeric type and does not participate in conversions;
generally byte, short, char Three do not convert to each other, but the byte, short, char directly into an int.
Conversion rules:
The space size of the respective type, (converted from small to large) look at the graph:
Consider different data types as containers of different capacities:
II. Basic Data type coercion (explicit conversion)
1 // assign a constant of type int directly to a variable of type byte 2 byte a = a; 3 // because the compiler found 125 in byte range, the underlying secretly converted the
View Code
Iv. automatic elevation of expression types
The string type and any type of data are concatenated using "+", and the result is a string (string) type.
First, the Java Language Foundation (2) _ Type and operation--basic data type conversion