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

The method multiply(long) from the type BigInteger is not visible

我正在尝试 运行 此代码:

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

但我收到错误消息:"The method multiply(long) from the type BigInteger is not visible"。 为什么会出现此错误,如何避免?

BigInteger class 中有一个包私有的 multiply(long) 方法,而您正试图从包外调用它,所以您得到该方法的错误不可见。从源代码看,这个方法是从Java 6.

开始出现的

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

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