float a = 1.5; Error: 1.5 is the default double type, double cannot be automatically converted to float type, need to cast float B = 1.5f; Compiled by byte = 1; Compile through/* Because in Java the value of the default value is int, when assigned to a numeric type variable that has a smaller range than the int type (this unification is called the numeric type k,k can be the Byte/char/short type), it is judged, If this int value exceeds the value type K, then a direct compilation error occurs. Because you assign a value that exceeds the range to a variable of type K, K does not fit, you have no coercion type conversion, of course, error. However, if the value of this int type is still within the value type K range, the JVM will customize an implicit type conversion to convert this int value to type K. */
byte m = 1, n = 2, c;c = 1+2; Compile by C = m+n; Error. Because the value of M+n may exceed the range of byte
c = m+2; Error
c = (byte) (m+n); Compiled by.
Reference: http://www.cnblogs.com/lwbqqyumidi/p/3700164.html
Type conversion related in Java