gpt4 book ai didi

java - BigInteger 类型的方法 multiply(long) 不可见

转载 作者:行者123 更新时间:2023-11-29 05:09:01 24 4
gpt4 key购买 nike

我正在尝试运行这段代码:

private static String reverseNumbers(BigInteger binaryBig){
BigInteger big = new BigInteger("0");
big.multiply(2);
}

但我收到错误消息:“BigInteger 类型的方法 multiply(long) 不可见”。为什么会出现此错误,如何避免?

最佳答案

BigInteger 类中有一个包私有(private)的 multiply(long) 方法,而您正试图从包外调用它,因此出现错误该方法不可见。从源码来看,这个方法是从Java 6开始出现的。

有一个public 重载,multiply(BigInteger) .改用它。 (您还需要将结果分配回另一个变量。)

big = big.multiply(new BigInteger("2"));

关于java - BigInteger 类型的方法 multiply(long) 不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29357960/

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