Changing BigInteger after division Java

I searched a lot here and can't 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 am I doing wrong?

+3


source to share


2 answers


You must first correct your Raw Type (and I would prefer List

), for example

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

      

then you need to use set

because you cannot assign the return value get

.



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

      

Also, it's worth noting that BigInteger

(s)
(immutable arbitrary precision integers for each Javadoc).

+6


source


=

works only for assigning variables, fields and array elements.

You probably want to call set

.



data.set(i, data.get(i).divide(...etc...));

      

+5


source







All Articles