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:eclipse
"The literal of int 9223372036854775807 is out of range.编辑器
#问题:为何我在eclipse编译器里面输入long abc= 9223372036854775807 ;而后会报spa
"The literal of int 9223372036854775807 is out of range.code
这样的错误呢?orm
##缘由####ip
貌似是编辑器检查的时候会出现问题。那么就是说编辑器去检查的时候会默认把数字看成 int 类型来检查。get
##解决方法###编译器
告诉编辑器,你所指定的并非int类型 ,在数字的后面加上后缀,若是float 加上 f/F,long 加上 l/L, double 加上d/D.it