Kotlin 代码
import java.math.BigInteger
fun main(args: Array<String>) {
println(BigInteger("1").longValue())
}
产生编译错误未解析的引用:longValue
(intValue
同上)。 BigInteger 的其他方法(例如 modInverse
)没有任何问题。除非有我没有看到的拼写错误,否则我很困惑为什么会发生这种情况......
最佳答案
正如评论中提到的,您可以使用 .toLong()
和 .toInt()
。此外,还有 longValueExact()
和 intValueExact()
。
.toLong()
实际上解析为 longValue()
(在 IntelliJ 中按 CTRL+单击),因此看起来这样做是为了符合语言标准。
关于kotlin - 未解析的引用 : [BigInteger]. longValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53146736/