简体   繁体   English

从BigInteger类型乘以(long)的方法不可见

[英]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". 但我收到错误消息:“BigInteger类型的方法乘(长)不可见”。 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. BigInteger类中有一个package-private multiply(long)方法,并且您尝试从包外部调用它,因此您会收到该方法不可见的错误。 It looks from the source code that this method shows up starting in Java 6. 从源代码看,此方法从Java 6开始显示。

There is a public overload, multiply(BigInteger) . 有一个public重载, multiply(BigInteger) Use it instead. 请改用它。 (Also you'll want to assign the result back to another variable.) (此外,您还需要将结果分配回另一个变量。)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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