cjy的学习日记

导航

Day010

Base

Demo05

public class Demo05 {
public static void main(String[] args) {
//操作数比较大的时候,注意溢出问题
//JDK7特性 数字直接可以用下划线分割
int money = 10_0000_0000;
int years = 20;
int total = money*years; //-1474836480 运算溢出了
long total2 = money*years; //默认是 int 转换之前就已经存在问题了

long total123 = ((long)money)*years;
System.out.println(total123);

// L l 的区别 (小写l容易被看成1 尽量用大写L



}
}

posted on 2021-07-08 16:50  cjy的学习日记  阅读(24)  评论(0)    收藏  举报