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);



}
}
posted @ 2021-09-15 19:02  山城旧客  阅读(26)  评论(0)    收藏  举报