I have a 2D ArrayList and I want to take one specific ArrayList from those that are inside the 2D ArrayList.
Is this possible?
If yes how can I do this?
How exactly does the 2D arrayList work, I have read a lot about it but I still can’t understand.
My 2D ArrayList has this form:
ArrayList<ArrayList<Items>> arrayList = new ArrayList<ArrayList<Items>>();
for (int i = 0; i < 10; i++) {
ArrayList<Items> row = new ArrayList<Items>();
for (int j = 0; j < 500; j++)
{
// create the items...
}
}
Starting from the top:
Is this possible?Yes, quite simple actually:
How does the 2D ArrayList work?Basically, it functions as an array of arrays, so that when you access one element of the 2D list, returns an ArrayList, which you must further call
get()on to get the element you want.Example: