Fortunately, there are all kinds of built-in classes that implement common data structures, and other useful tools too. You'll want to check Java6API for a full list of them.
ArrayList list = new ArrayList(4);
list.put(3,"Test");
It will give you an IndexOutOfBoundsException because there is no element at this position yet even though the backing array would permit such an addition. So you need to use a custom extendable Array implementation like suggested by @randy-lance