java data type precedence

From low to high: 
byte , Short , char -> int -> Long -> a float -> Double
  • 1. boolean type can not be cast.

  • 2. The object types can not convert into unrelated objects classes.

  • 3. must be cast at converting a large capacity type of a small capacity type.

  • 4. The conversion process may result in overflow or loss of accuracy

  • The floating-point to integer conversion is obtained by dropping the decimal, rather than rounded

E.g:

(int)23.7 == 23;         (int)-45.89f == -45
 

Guess you like

Origin www.cnblogs.com/jasonlai2016/p/11654946.html