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);
//结果正常
}
}