Tim R
Tim R

Reputation: 524

How to update a value in an arraylist<arraylist<Integer>>

I have an array list array list, I am trying to change the value in a specific element, but it tells me that the left hand side must be a variable. I am trying to update using this,

list.getMyList().get(4).get(5) = value;

Am I doing this incorrect, how would I update that element?

Upvotes: 0

Views: 909

Answers (1)

Jonah
Jonah

Reputation: 1003

Use this instead if you have a 2D ArrayList:

arrayLists.get(1).set(index, newValue);

Or this if you have a regular ArrayList:

arrayList.set(index, newValue);

Upvotes: 3

Related Questions