简体   繁体   中英

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

I'm trying to run this code:

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

But I get the error message: "The method multiply(long) from the type BigInteger is not visible". Why do I get this error and how can I avoid it?

There is a package-private multiply(long) method in the BigInteger class, and you are attempting to call it from outside the package, so you get the error that the method isn't visible. It looks from the source code that this method shows up starting in Java 6.

There is a public overload, multiply(BigInteger) . Use it instead. (Also you'll want to assign the result back to another variable.)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM