Package CN. zhao. base; </P> <p>/** <br/> * data type conversion <br/> **/<br/> public class mydemo <br/> {<br/> Public static void main (string [] ARGs) <br/> {<br/> // six normal sequence type conversions <br/> // byte-> short <br/> // short-> int <br // int-> long <br/> // char-> int <br/> // int-> double <br/> // float-> double </ p> <p> // conversion of precision may be lost <br/> // int-> float <br/> // long-> double <br/>/ /long-> float </P> <p> system. out. printl N ("when two numeric operations are performed, if one is double, the other is also converted to double"); <br/> system. out. println (3 + 3.0); </P> <p> system. out. println ("when two numeric operations are performed, if one is float, the other is converted to float"); <br/> system. out. println (3 + 3.0f); </P> <p> system. out. println ("when two numeric operations are performed, if one is long, the other is also converted to long"); <br/> system. out. println (3l + 3); </P> <p> system. out. println ("Otherwise, both numbers will be converted to int. Obviously, the result is incorrect because 200 is beyond the byte range and the precision is lost."); <br/> system. out. println (100 + (byte) (200); </P> <p> system. out. println ("------------------ forced type conversion -----------------"); <br/> system. out. println ("Double forced int conversion"); <br/> double num = 300.5; <br/> int intnum = (INT) num; <br/> system. out. println (intnum); <br/> // The result is 300. If the decimal point is converted to an integer, the decimal part is removed. <Br/> // if you want to perform exact conversion, you must use rounding. <br/> int intnumround = (INT) math. round (Num); <br/> system. out. println (intnumround); // 301 <br/>}< br/>