public class demo05 {
public static void main(String[] args) {
//操作数量比较大的数值时 注意溢出问题
//JDK7新特性 数字之间可以用下划线 _ 分割 并且不会被输出
int money = 10_0000_0000;
System.out.println(money);
System.out.println("==============================");
int years = 20;
int total = money*years;
long total2 = money*years;
System.out.println(total);//-1474836480 内存溢出
System.out.println(total2);//默认是int 转换之前已经内存溢出
System.out.println("==============================");
long total3 = (long)money*years;
System.out.println(total3);//20000000000 先把一个数值强制转换为long 计算是就会把整体都按long的级别来运算
}
}