java The literal of int 9223372036854775807 is out

I am working with data types at the moment in Java, and if I have understood correctly the type long accepts a value between the ranges of: -9,223,372,036,854 to +9,223,372,036,854,775,807. Now as you can see below I have create a Long variable called testLong, although when I insert 9223372036854775807 as the value, I get an error stating:

"The literal of int 9223372036854775807 is out of range.



#问题:为什么我在eclipse编译器里面输入long abc= 9223372036854775807 ;然后会报


"The literal of int 9223372036854775807 is out of range.


这样的错误呢?



##原因####

貌似是编辑器检查的时候会出现问题。那么就是说编辑器去检查的时候会默认把数字当作 int 类型来检查。



##解决方法###

告诉编辑器,你所指定的并不是int类型 ,在数字的后面加上后缀,如果float  加上 f/F,long 加上 l/L, double 加上d/D.

转载于:https://my.oschina.net/u/2308739/blog/633959

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值