Implementing abstract list
<p>I was looking at the <a href="http://docs.oracle.com/javase/tutorial/collections/custom-implementations/index.html" rel="nofollow">http://docs.oracle.com/javase/tutorial/collections/custom-implementations/index.html</a> tutorial and I tried to do the same :</p>

<pre><code>class MyArrayList&lt;T&gt; extends AbstractList&lt;T&gt; {

    private final T[] a;

    MyArrayList(T[] array) {
        a = array;
    }

    @Override
    public T get(int index) {
        return a[index];
    }

    @Override
    public T set(int index, T element) {
        T oldValue = a[index];
        a[index] = element;
        return oldValue;
    }

    @Override
    public int size() {
        return a.length;
    }

    @Override
    public Object[] toArray() {
        return (Object[]) a.clone();
    }

    public static void main(String[] args) {
        String[] arr = {"one", "two", "three"};
        MyArrayList&lt;String&gt; list = new MyArrayList&lt;String&gt;(arr);
        list.get(1);
        list.add(1, "seven");
        System.out.println(list);
    }
}
</code></pre>

<p>I get an exception while trying to insert the element :</p>

<pre><code>Exception in thread "main" java.lang.UnsupportedOperationException
    at java.util.AbstractList.add(Unknown Source)
</code></pre>

<p>Why is that, how do I fix it?</p>
