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.