T
Timo Nentwig
Hi!
I need a list to which I progressively add data to - at random indices.
So I set a List which ensures to have enough space for all items:
list = new ArrayList(max);
This does internally create an Object[] array of size <max>.
Unfortunately I cannot add at arbitrary indices as size() reflects only
the count of items already in the list and any access to an index
greater than size() throws an IndexOutOfBoundsException - despite the
index is not out bounds of the backing Object[] array.
So i do have to manually "initiliaze" the list *again*:
for (int i = 0; i < max; i++)
list.add(null);
Quite stupid... :-(
Timo
I need a list to which I progressively add data to - at random indices.
So I set a List which ensures to have enough space for all items:
list = new ArrayList(max);
This does internally create an Object[] array of size <max>.
Unfortunately I cannot add at arbitrary indices as size() reflects only
the count of items already in the list and any access to an index
greater than size() throws an IndexOutOfBoundsException - despite the
index is not out bounds of the backing Object[] array.
So i do have to manually "initiliaze" the list *again*:
for (int i = 0; i < max; i++)
list.add(null);
Quite stupid... :-(
Timo