I'm trying to implement ArrayList for my project, but I had some problem on the way. If anyone can help me, that would be wonderful.
I have this 3-dimensional array of string, iterated through it to have it hold some String values.
for(int x=0;x<array.length;x++){
for(int y=0;y<array[0].length;y++){
for(int z=0;z<array[0][0].length;z++){
array[x][y][z] = "Lorem ipsum";
}
}
}
But due to its flexibility of size, I've decided to use ArrayList instead.
The problem is, I have no idea how to iterate through a 3-dimensional ArrayList. Thought something like this would work, but it didn't.
ArrayList<ArrayList<ArrayList<String>>> arrSup = new ArrayList<ArrayList<ArrayList<String>>>();
for(int x=0;x<arrSup.size();x++){
for(int y=0;y<arrSup[0].size();y++){
for(int z=0;z<arrSup[0][0].size();z++){
array[x][y][z] = "Lorem ipsum";
}
}
}
So, can anyone tell me how to iterate through a 3-dimensional ArrayList?
Thank you.
List<List<List<String>>> arrSup = new ArrayList<>();thanks to the diamond operator.