基础学习-内存溢出问题
public class Demo3 {
public static void main(String[] args) {
// 内存溢出问题
// JDK7,下划线
int money = 10_0000_0000;
int year = 20;
int total = money * year; // -1474836480 内存溢出
System.out.println(total);
long total2 = money * year;
System.out.println(total2); // -1474836480 默认int
long total3 = money * (long)year; // 20000000000
System.out.println(total3);
}
}