public synchronized void add(int index,Object element){
  Object[] elements=getArray();
  int len=elements.length;
  if (index > len || index < 0)   throw new IndexOutOfBoundsException("Index: " + index + ", Size: "+ len);
  Object[] newElements;
  int numMoved=len - index;
  if (numMoved == 0)   newElements=copyOf(elements,len + 1);
 else {
    newElements=new Object[len + 1];
    System.arraycopy(elements,0,newElements,0,index);
    System.arraycopy(elements,index,newElements,index + 1,numMoved);
  }
  newElements[index]=element;
  setArray(newElements);
}

public synchronized void add ( int index , Object element ) { Object [ ] elements = getArray ( ) ; int len = elements . length ; if ( index > len || index < 0 ) throw new IndexOutOfBoundsException ( "Index: " + index + ", Size: " + len ) ; Object [ ] newElements ; int numMoved = len - index ; if ( numMoved == 0 ) newElements = copyOf ( elements , len + 1 ) ; else { newElements = new Object [ len + 1 ] ; System . arraycopy ( elements , 0 , newElements , 0 , index ) ; System . arraycopy ( elements , index , newElements , index + 1 , numMoved ) ; } newElements [ index ] = element ; setArray ( newElements ) ; }
inserts the specified element at the specified position in this list . shifts the element currently at that position ( if any ) and any subsequent elements to the right ( adds one to their indices ) .
