Data type conversion java_

First, the automatic conversion

      The purpose type is larger than the original type, the two data types are compatible with each other.

      byte--->short

      short--->int

      char--->int

      int--->long/double

      float--->double

If there is a double, the other is converted to double, double result is two numbers.

Otherwise, the two numbers is a float, the other is converted to float

Otherwise, if there is a long-type two operands, it is converted into another type long

Otherwise, the two numbers are converted to an int

Second, the cast

       :( syntax conversion of data types) variables need to convert

      Float transferred to integer - the number of decimal places amputated, reserved integer

     Long integer assigned to bit short integer ---

 

Guess you like

Origin www.cnblogs.com/liyongmei/p/10955911.html