Suppose that I have an Array list of Array lists:
A = [2, 5, 6], [1, 6, 1], [], [7, 7], [4, 2], [9, 3]]
and I want to split them at the index where the element of the array list has the size of 0 so that it will look like this
x = [[2, 5, 6], [1, 6, 1]]
y = [[7, 7], [4, 2], [9, 3]]
but whenever I run my loop it comes out like this:
for(int i = 0; i < A.size(); i++) {
ArrayList temp= A.get(i);
int size = temp.size();
if(size != 0) {
x.add(temp);
}
y.add(temp);
}
x = [[2, 5, 6], [1, 6, 1], [7, 7], [4, 2], [9, 3]]
y = [[2, 5, 6], [1, 6, 1], [], [7, 7], [4, 2], [9, 3]]
Can anyone please help me figure this out?