I have a arrayList done this way:
ArrayList<ArrayList<Double>> level = new ArrayList<ArrayList<Double>>(levels + 1);
So something like: enter image description here
What I would do is add a new element to the internal list saved in a certain index i
of the external list. How can I do this?
I can't use method arrayList.add(i, 0.0);
.
Use index from the external ArrayList
and use it to add the number. Like this
level.get(i).add(1.1);
You need to get the list at a given position first and then insert into it the value desired.
final List<List<Double>> listOnList = new ArrayList<List<Double>>();
listOnList.add(new ArrayList<Double>());
listOnList.get(0).add(155.0);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.