Demo05
public class Demo05 {
public static void main(String[] args) {
int money = 10_0000_0000;
System.out.println(money);
int years = 20;
int total = money*years;
System.out.println(total);//-1474836480, 计算的时候溢出了
long total2 = money*years;//默认是int,Z转换之前已经出现问题
long total3 = money*((long)years);//先把一个数转换long再进行
System.out.println(total3);
}
}

浙公网安备 33010602011771号