3

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?

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

Comments

5

= only works to assign variables, fields and array elements.

You probably want to call set.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.