gpt4 book ai didi

Java - : long n = 8751475143; 错误

转载 作者:行者123 更新时间:2023-12-01 06:28:09 24 4
gpt4 key购买 nike

这个数字属于长范围,那么为什么我会收到错误:

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

An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise it is of type int (§4.2.1). The suffix L is preferred, because the letter l (ell) is often hard to distinguish from the digit 1 (one). [..]

关于Java - : long n = 8751475143; 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10801003/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com