Java - 错误:long n = 8751475143; [英] Java - Error on: long n = 8751475143;
本文介绍了Java - 错误:long n = 8751475143;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个数字属于长距离,所以为什么我会收到错误:
This number falls into the long range, so why do I get the error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The literal 8751475143 of type int is out of range
推荐答案
成功
long n = 8751475143L;
L
将使其长文字
默认情况下它的 int
如果整数文字后缀为ASCII字母L或l(ell),则其长度为long;否则它的类型为int(§4.2.1)。后缀L是优选的,因为字母l(ell)通常难以与数字1(一)区分开。 [..]
这篇关于Java - 错误:long n = 8751475143;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文