Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying bigInteger after dividing Java

I've looked a lot through here and can't quite find why this line is wrong:

ArrayList <BigInteger> data = new ArrayList();
int [] primes = new int[25];    
...
// Some initializing
...
data.get(i) = data.get(i).divide( BigInteger.valueOf( primes[place] ) ); //<----
...
// Rest of the code

Required: variable; Found: value.. What I'm doing wrong?

like image 478
Zasito Avatar asked Sep 05 '26 15:09

Zasito


1 Answers

First, you should fix your Raw Type (and I'd prefer the List interface) like

List<BigInteger> data = new ArrayList<>();

then you need to use set because you can't assign to the return value of a get like that.

data.set(i, data.get(i).divide(BigInteger.valueOf(primes[place])));

Also, it's worth noting that BigInteger(s) are (per the Javadoc) immutable arbitrary-precision integers.

like image 120
Elliott Frisch Avatar answered Sep 08 '26 05:09

Elliott Frisch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!