2
public class SimpleArrayList  // Fig 4.23, Pg 121, Example of a Wrapper
{
    public SimpleArrayList( )
    {  clear( ); }
   
     public int size( )
    {  return theSize;  }
   
    public Object get( int idx )
    {  if( idx < 0 || idx >= size( ) )
            throw new ArrayIndexOutOfBoundsException( "Index " + idx + "; size " + size( ) );
        return theItems[ idx ];   
    }
       
    public boolean add( Object x )
    {  if( theItems.length == size( ) )
        {
            Object [ ] old = theItems;
            theItems = new Object[ theItems.length * 2 + 1 ];
            for( int i = 0; i < size( ); i++ )
                theItems[ i ] = old[ i ];
        }
        theItems[ theSize++ ] = x;        
        return true;           
    }
    private int theSize;
    private Object [ ] theItems;   
}