强制转换

public class daolao5 {
public static void main(String[] args) {
//操作大的数据时注意一出问题
//数字下可以加下划线分割
int money = 10_0000_0000;
int years = 20;
int total = moneyyears;//-1474836480,计算溢出
long total2=money
years;//默认时int,转换long前有问题

    long total3=money*((long)years);//先把一个数转化成long
    System.out .println(total3 ) ;
}

}

posted @ 2021-03-08 22:22  哎嘿嘿嘿  阅读(113)  评论(0)    收藏  举报