public class Demo05 {
public static void main(String[] args) {
//操作数字比较大的时候,注意溢出问题
int money = 10_0000_0000;
int years = 20;
int total = money*years;
System.out.println(total);//计算溢出
long total2 = money*years;
System.out.println(total2);//默认是int,转换之前已经计算溢出
long total3 = money*((long)years);
System.out.println(total3);//先把一个数转换为long,整个公式就变成了long型
}
}
还需注意尽量注意大小写
1131

被折叠的 条评论
为什么被折叠?



