private void resize()
    {
        Object [] newArray = new Object[2*this.capacity];
        for (int i = 0; i < this.size; i++)
            newArray[i] = this.array[i]; // copy elements to new list
        this.array = newArray; // make array the new list
        this.capacity *= 2;        
    }