This is what happens when you add array list a
to array list j
10 times.
This is what happens when you add 1
to the list of array a
.
Thus, basically all 10 ArrayList j
indices point to one ArrayList a
. Therefore, printing a value from any index j
will always give you the same result.
So that each pointer points to a different list of arrays:
source share