Any help? Please?
I would like to know- initialising an ArrayList with a default size, eg, ArrayList list =new ArrayList<Object>(30);
will this create an ArrayList with 30 null values?
Also, would invoking set(int index, Object element);
result in an IndexOutOfBoundsException if done on the ArrayList as initialised above? If yes, what should be done instead?
Any help would be appreciated... Thanks
'Segun
[501 byte] By [
Oluseguna] at [2007-10-2 20:44:15]

> I would like to know- initialising an ArrayList with
> a default size, eg, ArrayList list = new
> ArrayList<Object>(30);
will this create an
> ArrayList with 30 null values?
It will create an ArrayList that doesn't have any values.
The underlying array will have 30 null values.
> Also, would invoking set(int index, Object
> element);
> result in an IndexOutOfBoundsException if done on the
> ArrayList as initialised above?
Try it.
> If yes, what should
> be done instead?
Depends. What are you trying to accomplish? Putting something in position 20 in an ArrayList that has fewer than 20 elements is meaningless.
jverda at 2007-7-13 23:27:41 >

> Try it.Thanks for the info... I tried it, the exception got thrown.I'm trying to set the list contents to particular values, one by one, in a for loop.'Segun