【笔记】Java 里使用 long 类型的数据一定要在数值后面加上 L
【摘要】 long g = (long)9223372036854775807;long h = (long)-9223372036854775808;或者long g = 9223372036854775807;long h = -9223372036854775808;会出现以下报错信息:Exception in thread "main" java.lang.Error: Unresolved ...
long g = (long)9223372036854775807;
long h = (long)-9223372036854775808;
或者
long g = 9223372036854775807;
long h = -9223372036854775808;
会出现以下报错信息:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The literal 9223372036854775807 of type int is out of range
The literal 9223372036854775808 of type int is out of range
溢出了~
解决方法在数值后面加上 L:
long value = 9223372036854775807L;
转载自 大白兔 ali***990@foxmail.com
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)