Java如何处理整数下溢和溢出?
在此之后,您将如何检查/测试这是否正在发生?
为什么我需要添加"L"字母才能获得正确的长值?另一个价值是什么?
long oneYearWithL = 1000*60*60*24*365L;
long oneYearWithoutL = 1000*60*60*24*365;
System.out.println(oneYearWithL);//gives correct calculation result : 31536000000
System.out.println(oneYearWithoutL)//gives incorrect calculation result: 1471228928
Run Code Online (Sandbox Code Playgroud)