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