低------------------------------------------->高
byte,short,char->int->long->float->double
public class Demo{
public static void main(String[] args){
int i = 111;
byte b = (byte)i;
}
}
public class Demo{
public static void main(String[] args){
int money = 1000000000;
int years = 20;
int total = money*years;
//结果为-1474836480,数据溢出
long total1 = money*years;
//结果仍然溢出
long total2 = money*((long)years);
//结果正常
}
}
原文:https://www.cnblogs.com/skylinxun/p/15095658.html